Re: Shall we leave PHP4 ??

[email protected] (Keith Roberts) Tue, 26 Jun 2007 15:25:20 +0100 (BST)
Newsgroups php.evangelism
Message-ID <[email protected]>
In a word yes! Please see below for my reasons for saying 
this.

On Tue, 26 Jun 2007, Anugrah Widya wrote:

> To: [email protected]
> From: Anugrah Widya <[email protected]>
> Subject: Shall we leave PHP4 ??
> 
> Hello everyone, i would like to tell my concern in php
>
> my concern is about php4 development, i think is not wise have php in 3 
> different version 4, 5, 6 in next year and each have different specific 
> capabilities.
>
> why should keep php4 in production, if the reason is still lot of user 
> using it, then php will have 3 version in next year 4, 5, 6. at that time 
> the standard of web-developing will have ambiguity, developer use php 
> will confuse, not just developer actually, hosting provider also will 
> need to invest more to make their service at it best (to buy three server 
> for each php version).
>
> IMHO migrating tips and trick is not efficient right now, if new version 
> of php4 still released, migrating efforts will rise exponentially at the 
> time php4 development is stop, so why don;t the php-group stop the 
> development of php4 now, while the effort is till in the level of 
> acceptance!!!
>
>
> WE WANT FIVE!!!!

PHP 5 has a backward compatible mode that you can use for 
PHP 4 scripts. Maybe PHP 6 will offer a similar capability 
as well.

So there is no need to host different versions of PHP 
AFAICS.


php.ini has a configuration directive:

zend.ze1_compatibility_mode  "0"  PHP_INI_ALL  Available 
since PHP 5.0.0.

PHP_INI_ALL  7  Entry can be set anywhere

zend.ze1_compatibility_mode boolean

Enable compatibility mode with Zend Engine 1 (PHP 4). It 
affects the cloning, casting (objects with no properties 
cast to FALSE or 0), and comparing of objects. In this mode, 
objects are passed by value instead of reference by default.

See also the section titled Migrating from PHP 4 to PHP 5.

This can also be set at the top of an include script, for 
users that want to run PHP 5 in PHP 4 mode.

So you could configure PHP 5 to run in PHP 5 mode in 
/etc/php.ini, and for those users that want PHP 4 backward 
compatibility, tell them to use the following line at the 
start of their PHP 4 scripts,

ini_set(zend.ze1_compatibility_mode, ON)

Or an even better option would be to set the PHP mode in 
Apache httpd.conf file, or .htaccess files with something 
like:

<Directory /srv/www/htdocs/path/to/users/DocumentRoot/>
   # Order deny,allow
   # Deny from all
   #
   # set to PHP 4 mode for ALL scripts
   # in this users directory
   php_flag zend.ze1_compatibility_mode ON
</Directory>

How to change configuration settings
Running PHP as an Apache module

When using PHP as an Apache module, you can also change the 
configuration settings using directives in Apache 
configuration files (e.g. httpd.conf) and .htaccess files.

You will need "AllowOverride Options" or "AllowOverride All" 
privileges to do so.

With PHP 4 and PHP 5, there are several Apache directives 
that allow you to change the PHP configuration from within 
the Apache configuration files. For a listing of which 
directives are PHP_INI_ALL, PHP_INI_PERDIR, or 
PHP_INI_SYSTEM, have a look at the List of php.ini 
directives appendix.

php_flag name on|off

Used to set a boolean configuration directive. Can be used 
only with PHP_INI_ALL and PHP_INI_PERDIR type directives.

So the easiest option would be to set the compatibility mode 
for each users Document root in Apache configuration files. 
Maybe you allow users to write their own .htaccess files ?

Personally, I like to set all my apache configuration 
options in one global httpd.conf file. Multiple .htaccess 
files can slow down apache, as they are read each time a 
directory is accessed. httpd.conf is read only once, at 
Apache start time.

HTH

Keith

------------------------------------------------------------
http://www.karsites.net
http://www.raised-from-the-dead.org.uk

This email address is challenge-response protected with
http://www.tmda.net
------------------------------------------------------------