Re: PHP3 vs PHP4

by "Srinivasan Ramakrishnan" <srinivar(at)md3.vsnl.net.in>

 Date:  Thu, 2 Nov 2000 18:23:21 +0530
 To:  <9705228b(at)student.gla.ac.uk>,
<hwg-languages(at)hwg.org>
 Cc:  "Rajnish Bhaskar" <r.bhaskar(at)compserv.gla.ac.uk>
 References:  ac
  todo: View Thread, Original
Hi,

As has already been mentioned by many PHP4 has native support for sessions
and the much touted XML. While this makes PHP a competitor in the
application server languages arena, there is another core aspect to PHP4. It
is faster.

PHP3 used to parse line by line, while PHP acts like a compiler. This along
with the Zend optimizer makes PHP4 almost always faster than PHP3.

I'm not sure about support for COM, it has caught my attention only in PHP4.
If it was present in PHP3 I was not aware of it.

Plus PHP4 can run as an Apache module, again this could have come in the
late versions of PHP3.

However I can see some huge bugs in PHP4 which mean that PHP will not be a
mature language until say PHP5.

To substantiate my claim, here is an example:

$abc[5]

What do you call this?

An array? Wrong!

Look at this code::

<?php

    $a = "abc[0]";
    $$a = 123;
    echo "\$$a is an " . gettype($$a);
    echo "\n";

    echo "\$$a = ";
    echo var_dump($$a);

    if(isset($abc)){
        echo "Set";
    }else{
        echo "Not Set";
    }

?>

Now does a variable like $abc[0] exist or not? If it does is it an array or
an integer?


The output is:

<output>

$abc[0] is an integer
$abc[0] = int(123)

Not Set

</output>

If we wanted an array of $abc, then we should have used the following
syntax:

$a = "abc";
$$a{[0]} = 123;

This would have created $abc an array with $abc[0] = 123

However we have an impossible condition here, an integer variable with an
impossible array like name has been created defying all variable naming
conventions!!

This goes to show that the PHP parser is still immature. However I do not
mean to say that PHP is not robust. Used carefully and with some knowledge
of its workings you can have a very good solution. I think PHP's claim to
fame is its C like syntax and that it is open source. Being open source is
very important. For one you have a very responsive mailing list (PHP
General) and all the code is free. Try finding a library like Phplib for
free in the ASP or CFML market!

Plus the present version of PHP does not have a database independent data
access function, except ODBC. If you use mySQL your code is different from
say Oracle code, this can cause scalability problems! There is the Pear
project which seeks to unify the database functions, but that is some time
in the future.

Again if you are looking for sheer power, PerlDBI is more powerful, but then
the choice of a language depends not just on the technical prowess of a
language alone, but also on availability of manpower, ease of implementation
etc.

Anyway I'd definitely use PHP4 if you are looking at a small to medium
operation. However if you are planning something like Yahoo or Hotmail I'd
stay away. If you are worried about performance problems down the road,
forget it, PHP is bound to improve, and I predict that PHP will be as good
if not better than any other language for internet servers a couple of years
from now.

For a fairly huge PHP implementation look at http://sourceforge.net

All the best in your venture,

Cheers,
Srini

----- Original Message -----
From: Rajnish Bhaskar <r.bhaskar(at)compserv.gla.ac.uk>
To: <hwg-languages(at)hwg.org>
Sent: Wednesday, November 01, 2000 8:14 PM
Subject: PHP3 vs PHP4


> Hi all,
> I was just wondering what the differences are between PHP3
> and PHP4?  I am planning a site for a major uni project based
> around PHP, but most (okay, all) of the commerical ISPs that I've
> looked at (in the UK) seem to still be running PHP3.
>
> Thanks,
> Raj.
>
> --------------------------
> Rajnish Bhaskar
> r.bhaskar(at)compserv.gla.ac.uk, http://i.am/rajy
> IT Education Unit, University of Glasgow
> http://www.iteu.gla.ac.uk/
> --
> Sometimes it's better to light a flamethrower than curse the darkness.
>         -- (Terry Pratchett, Men At Arms)
>
>

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA