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…
Why is $(document).ready not firing for me?
In a php file i have used include to include the following js.php file and prior to that i have included the jquery file. $(document).ready(function(){ …
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…
Image Upload — showing image on web page before hitting Submit
To better learn web development, I’m trying to write a PHP page that will let me upload and download files from a server, which I’ve done in ASP before. I am however, tripping over something that reason says should be simple, but I’m not able to find an answer for it. Here’s the pretty…
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…
How to reduce the number of if-else statements in PHP?
I found that there are many if-else statements, especially nested if else statements, these statements make my code less readable. How to reduce the number of if else statements in PHP? My tips are as follows: 1.Use a switch statement when it is suitable; 2.use exit() statement when it is feasible; 3. Use ter…
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…