Skip to content

Get parent directory of running script

In PHP, what would be the cleanest way to get the parent directory of the current running script relative to the www root? Assume I have: $_SERVER[‘SCRIPT_NAME’] == ‘/relative/path/to/script/index….

Cannot use string offset as an array in php

I’m trying to simulate this error with a sample php code but haven’t been successful. Any help would be great. “Cannot use string offset as an array” Answer For PHP4 …this reproduced the error: For PHP5 …this reproduced the error: (From bugs.php.net actually) Edit, so why d…

Passing custom variables to paypal IPN

I am trying to pass custom variables to paypal IPN. I can manage to pass one variable. But i don’t know how to pass multiple variables. My Process is something like this User fill up the form They …

How to use XMLReader in PHP?

I have the following XML file, the file is rather large and i haven’t been able to get simplexml to open and read the file so i’m trying XMLReader with no success in php I’ve unfortunately not found a good tutorial on this for PHP and would love to see how I can get each element content to s…

JetBrains WebIDE: PHP variable type hinting?

Is there a way to hint WebIDE that a variable has some type? I have to iterate an array of objects, and there’s no auto-completion available. This helps in ZendStudio: I know there’s a feature in JetBrains to declare an array of objects: But this works only with function’s return type. Answe…

Tracking the views of a given row

I have a site where the users can view quite a large number of posts. Every time this is done I run a query similar to UPDATE table SET views=views+1 WHERE id = ?. However, there are a number of disadvantages to this approach: There is no way of tracking when the pageviews occur – they are simply increm…

Variable type hinting in Netbeans (PHP)

Just curious if there’s a way in netbeans to give type hints for regular variables, so that intellisense picks it up. I know you can do it for class properties, function parameters, return types, etc. but I can’t figure out how to do it for regular variables. It’s something that would really…