This one drove me nuts.
I was compiling various versions of PHP4 on Mac OS X and even though the phpinfo() was saying that it was loading the php.ini at /usr/local/php/php.ini it really wasnt (still haven’t figured out what it was loading).
But after trawling about for a while, I found this excellent forum post that told me how to get my compiled PHP to load the right php.ini
compile PHP with these flags
–sysconfdir=/etc –with-config-file-path=/etc –with-config-file-scan-dir=/etc/php.d
substituting the correct folder paths for each of the flags
I was going through my google analytics logs today and I noticed that a lot of folks were coming to my site on Google searches for stuff like ‘print_r + ruby on rails‘.
So I figured I’d write a blog post about it, because I’ve had the same problem.
What you’re looking for is ‘inspect’.
If you have an array, hash or object that you want to take a quick-and-dirty look at just type in
or if you’re in rails just do …
render :text => posts.inspect and return false
and you’ll get an output of the contents of said array, hash or object.
Here is a screen capture of a quick irb session to show you how it works.
I hope this helps.
The more I work with Ruby and Ruby on Rails, the more I begin to understand (though not necessarily agree with) a lot of the vitriol that has been aimed at PHP over the years by developers using other more rigorous languages.
A few weeks back I ran into this little speed bump while working with Ruby on Rails, where I was trying to do a multiple assignment like this
Most seasoned Rubyists will be waving their arms around and yelling “NOOOOOO!!!”
But coming from a PHP background this seemed perfectly okay to me.
I have just blown 4 – 5 hours on this “feature” of PHP and I thought someone else would care to know.
You can’t use numeric keys for sessions in php! Continue reading
“We have to reinvent the wheel every once in a while, not because we need a lot of wheels; but because we need a lot of inventors.”
– Bruce Joyce
I wrote about my experience writing a site crawler in php in an earlier post, and I’m going to use some of the background there to make my point here. So it might help to go read it if you haven’t already.
[Google’s crawler [Googlebot] isn’t that sophisticated/writing a crawler in php]
From my casual observation of the way Googlebot crawls some of the sites I work on, I have reached the conclusion that it works in much the same way that a crawler I wrote a year ago worked.
Google bot goes page to page, gathering links from your page and tacking them onto the current url that it is at, right then. So why do query strings give it such a problem? Continue reading
I spent a lot of time early last year, trying to write a crawler in php (I know, I know).
It was supposed to sit on the server and when so that when you went to the url, it’d generate a google sitemap for your entire site.
What I found out was that writing a good crawler is very hard work. Not because of the recursion involved, but because of the infinite ways link tags appear.
Now Google has validated my experience (more on this in a second).
I was trying to take advantage of PHP5’s new auto_prepend_file directive today, by using the php_value directive to set it in a .htaccess file. But as soon as I did that, my cheerfully running application puked and died, with the familiar message.
“Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request”
I had seen this behavior before, when I was writing an app for a client a few months ago, but I hadn’t had time to investigate it. Today I decided to go a-googling and I promptly found my answer …
Those are Apache directives, but in CGI mode Apache calls the php binary, which turn reads php.ini. Since the binary doesn’t read httpd.conf it has no effect on PHP. As PHP isn’t loaded into Apache, Apache doesn’t know what to do with the directives and borks.
I finally made the jump from mysql 4 the other day, to take advantage of mysql’s new “INSERT … ON DUPLICATE UPDATE” command (which I think is spectacular by the way).
I didn’t want to actually upgrade from mysql4 to mysql5, just run the two mysqls side by side … so I looked around for a bit and figured out that all you need to do is get both servers running on different ports. The trick is to remember to reference localhost:port (eg: “localhost:3307”) instead of just “localhost” whenever you connect to it, in php, for example. Below are screenshots of the things you need to watch out for when doing this on a windows machine. Continue reading
Ian Bickings’s “What PHP Deployment gets right”
This is a wonderfully written article on how PHP works, and the funny thing is that Ian seems to be more of a Python guy than anything. Needless to say, I learned a few things from reading this … Continue reading
For all you php debuggers out there losing time looking up xdebug settings in xdebug’s difficult-to-look-up documentation …
now you have this …
A well documented and well commented xdebug.ini by Gaetano Giunta.
So … I’m running Windows XP on a 17″ Macbook Pro with Bootcamp …
Every now and then, when I put the laptop on Standby and try to resume work from where I left off, the USB devices stop responding all together.
This is a big problem for me, since
- I put my laptop in and out of standby several times a day
- work off an external 250GB Hard drive.
- am pretty hopeless without a wireless mouse
I poked around online, but didn’t really find anything on Google or at the Apple bootcamp forum.
So I decided to try fixing it on my own. Continue reading