Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP Development & Design Question

Status
Not open for further replies.

gwinn7

Programmer
Feb 10, 2001
1,004
US

Why have the developers of PHP chosen to create a huge list of functions when each of these functions could be represented by a smaller number of functions distributed through an object model?

It seems to me that many of the functions are rather unnecessary as they could be consolidated into a single operation.

Example:

Image functions in PHP could be called from the IMAGE object. Hypothetically, something like this...

$obj = new Image;
$obj.Vsize = 200;
$obj.Hsize = 200;
$obj.BorderStyle = "Rectangle";
$obj.BorderWidth = 0;
$obj.Create("myjpeg.jpg","JPG")
$obj.Render

The above example instantiates the Image class into the object and, through properties, set individual characteristics of the image. Then, create the image from the JPG file and render the image to the browser.

PHP has several completely different sets of functions to deal with database programming. Why not unify it like ADO or DAO?

This code seems much simpler and efficient than a pool of functions.

For the past three years I have been a busy Microsoft Access developer. So, I am used to working with the various object models that Microsoft had exposed (ie. ADO, DAO, etc). Making the transition to PHP has been great. I like to code PHP pages. I just thought I would give my perspective on this issue to see the response.

Gary
gwinn7
A+, Network+


 
PHP doesn't do everything itself. It simply uses the libraries that other programs provide. For example, the images are created by the GD library. Same thing with databases. PHP just uses the libraries distributed with the databases, the PHP developers hasn't created the interfaces themselves. //Daniel
 
Well, I understand that PHP is using calls to libraries made available by other interfaces, but they are still providing an interface to those functions. Therefore, why not unify/simplify things a bit?

Gary
gwinn7
A+, Network+
 
It boils down to two requirements: performance and platform agnosticism.

ADO and DAO place a layer of abstraction between the caller and the instrinsic code and that abstraction really causes a performance hit. One of my great disappointments was when Mi¢ro$oft dropped development of db-lib for c when they released SQL Server 7. With that native communications code, I could make SQL Server fly.

Also, all those database servers have functions that are peculiar to them. PostgreSQL, for example, does not support an equivalent to MySQL's last_insert_id() because PostgreSQL's entire autoincrement system is completely different from MySQL's. By PHP's mapping functions directly to library calls instead of wrapping everything in an abstraction of objects means that you can better and more efficiently use the native features of the database server.


Look at the problems Mi¢ro$oft has getting their own software to run right on their own operating systems. I can't count the number of times a VB app has broken when the program was installed on a machine other than the one on which I developed it, simply because the user of the foreign machine hadn't ever installed "Mi¢ro$oft Foo". Now multiply that by the fact that PHP can not only run with operating systems as disparagate as Win32 and Linux, but also with web servers as different as Apache and IIS. ______________________________________________________________________
TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top