Closing PHP tag considered harmful

php — Tags: , , , , — Glen @ 2:28 pm

A good tip from Zend, who recommend omitting the closing PHP tag (?>) when your files contain pure PHP code. This can prevent additional whitespace being inserted into the script output. Extra whitespace can cause problems, for example, if you are trying to set your own custom HTTP headers: nothing should be output before the call to the header function. Otherwise, this classic error will occur:


Cannot modify header information - headers already sent by (output started at myinclude.php:16) in myscript.php on line 15

Zend Framework: Documentation

Share/Save/Bookmark

Cal Henderson on Django

flickr, webapps, yahoo — Tags: , , , , , — Glen @ 2:25 pm

Very entertaining talk from Flickr’s Cal Henderson on Django’s shortcomings.

Share/Save/Bookmark

Installing PEAR on Mac OS X 10.5 Leopard

mac, php — Tags: , , — Glen @ 6:34 pm

PEAR was removed by Apple from 10.5 for one reason or another. Here’s how to get it back:

Pre-requisties

Make sure you have a php.ini file in /etc/. This isn’t available by default. To create one enter the following:

sudo cp /etc/php.ini.default /etc/php.ini

PEAR Install

  • cd
  • curl -O http://pear.php.net/go-pear
  • sudo php go-pear

This starts the interactive install script.

  • Press Enter to start install
  • Press Enter to use no HTTP proxy
  • Type 1 and press Enter
  • Enter /usr/local/pear as the path and press Enter
  • Press Enter to confirm the install directories
  • Press Enter to install PEAR_Frontend_Web-beta,
    PEAR_Frontend_Gtk2, MDB2 by default

The installer will also alter the include_path in your php.ini file to include the new installation directory, so just press Enter when prompted

The PEAR Package Manager

To make using the command line tool easier, we are going to modify our shell path. Add the following line to the end of your ~/.profile file:

export PATH="$PATH:/usr/local/pear/bin"

After saving your .profile file, log into a new terminal and type the following to confirm that everything is working

pear version

If all is well, you should see the following output (or similar):

PEAR Version: 1.7.2
PHP Version: 5.2.5
Zend Engine Version: 2.2.0
Running on: Darwin glen-scotts-macbook.local 9.3.0 Darwin Kernel Version 9.3.0: Fri May 23 00:49:16 PDT 2008; root:xnu-1228.5.18~1/RELEASE_I386 i386

For more information on using the manager to install and maintain packages, see the PEAR manual for the command line installer.

Clean up

rm go-pear

Share/Save/Bookmark

The Problem with PEAR

php — Tags: , , — Glen @ 2:34 pm

I have a love-hate relationship with PHP’s class repository (and answer to Perl’s CPAN), PEAR. Sometimes you can find very useful, well documented and cleanly implemented packages. And obviously re-using such components is a big-win. Sadly, the quality of PEAR varies wildly and frequently I stumble upon useful looking packages that have little or, worse, no documentation. This situation, regardless of the underlying code, puts me off more than anything.

It’s odd, as writing examples and documentation is a pre-requisite for new PEAR package submissions. The question is, should the PEAR developers be more strict on what they let in?

PEAR :: The PHP Extension and Application Repository

Share/Save/Bookmark

Java fighting a losing battle

computing, programming — Tags: , , — Glen @ 4:37 pm

Interesting article from Zend co-founder Andi Gutmans on how the Java world is leveraging dynamic languages such as Ruby and PHP in order to remain relevant in the web application world. The obvious question is, though, whether using JRuby has enough advantages over using Ruby or PHP in a plain Linux environment without a JVM.

Today Sun is investing in JRuby Ruby and Jython Python support for its Java EE solution; the IBM Websphere group has realized the ineffectiveness of the Java EE platform for running modern Web workloads and has invested heavily in Project Zero which aims to make big blue a Web 2.0 player and initially delivers support for Groovy and PHP; BEA has also had some incubation projects going but with the upcoming sale to Oracle it is unclear whether any of those efforts will materialize.

Andi on Web & IT: Java is losing the battle for the modern Web. Can the JVM save the vendors?

Share/Save/Bookmark

Creator of Ruby on Rails pays backhanded compliment to PHP

programming — Tags: , , — Glen @ 5:01 am

David Heinemeier Hansson, the creator of Rails, praises PHP for being adequate for “small chores”. Wow, what a compliment! Perhaps someone should suggest to Dave that Rails is okay too, as long as you don’t care about performance.

The immediacy of PHP

Share/Save/Bookmark

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2008 Glen Scott - Keeping it simple, since 1977 | powered by WordPress with Barecity