I had an issue getting phpsh to work on my mac - I kept getting the following error:
Traceback (most recent call last): File “./phpsh”, line 20, in import readline
OK, seems easy enough. So I compiled python with readline support.
./configure –prefix=/usr/local/python –enable-readline
I change the PATH variable in my .bash_profile to point to the /usr/local/python directory first, and source’d it to get the new PATH settings. Still get the same error.
php
- If you manually call ob_start() at the beginning of your script, you might notice that you are unable to use phpsh. By commenting it out, I was able to fix the issue. I don’t think it technically hangs, it just sits there with the data in a buffer waiting to be flushed.
- I’ll be honest, this isn’t very useful. The goal was to have an array of months in the least amount of code. for($i = 1; $i <= 12; $i++) $months[$i] = date('F', strtotime("{$i}/01/2000"));
- Perhaps you’d like to just sent XML over post, and not have xml=your_nodes_and_stuff_here. No sweat. $xml = urldecode(file_get_contents('php://input')); Enjoy. This can now be called with: curl -d "some_xml_here" http://yoursite.com/pagename
- In trying to get a site working on cell phones, I got a “406 Not acceptable” only on the Motorola RAZR. The site loaded fine on my Treo 755 and every Blackberry I’ve tried. It seems that the RAZR doesn’t handle Multiviews very well, or at all for that matter. If you’re using Multiviews and Apache, you’ll have to specify the full URL: so /login.php rather just /login.
- I’m migrating a PHP 4 site right now. It makes me realize how far PHP has come in the last few years. I ran across a weird bug where code was working on our dev server, but not production. I was getting the error: session_start(): Failed to initialize storage module We’re using memcache to store our sessions, so it’s a user storage module. Luckily, I stumbled across this helpful post. [edit: I only checked the page on our production box directly (not going through the load balancer) after I made this change, so it seemed to fix the problem, but the issue was really caused by the fact that I wasn’t defining the custom session handler when it was hit by the LB]
- KCacheGrind is a very useful tool to identify bottlenecks in your applications. This will explain the steps to using it to find issues with your PHP scripts. For me, the scripts are all web pages. I’m already assuming you’re running a current version of PHP. I did this using PHP 5.2.1. These instructions are based on a Unix/Linux server, if you’re running Windows I can’t help you. **Step 1: Install XDebug.
- I installed CentOS 5 on my VMWare a few days ago. I installed gcc via yum, compiled and installed libxml2. I then tried to install PHP 5.2.3 and received this error: configure: error: installation or configuration problem: C++ compiler cannot create executables. It took me forever to figure this out, but I had to install the g++ library, then it compiled fine. yum install gcc-c++
- Barebones list for the things you should be looking for when developing a web app in PHP. Some of it applies to all web apps, not just PHP. Use HTML_Safe (or a similar javascript stripping library) to check for and remove javascript when you’re accepting data that will be output to a page. Check every get and post variable for validity. Every web site has url like “dosomething.php?id=3”. Make sure that id you’re accepting is actually a number (or whatever type you’re allowing).
- Every now and then, we find that we will have a sudden increase in the number of apache processes, load average will spike up, and then go back down to normal. In rare cases, we will see the same thing happen, and the load avg spike WAY up, all queries appear locked up, and the server must be rebooted. I am looking for ways of determining what caused this. I should note that it happens extremely rarely, and has never shown up in a load test.