php functions

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Is that true the PHP library is just a list of functions?

When i read sample PHP code, I don't seem to see any calls to init
Class objects like Java or C++ does

Is that most of the time, PHP will call functions only in the PHP

also, when calling PHP function, I don't seem to see the need to
include the source file contain the function like java and C++ does.

Is that true PHP do not need to include for the stand library?


include <iostream>

Re: php functions

Quoted text here. Click to load it

No need to create objects in procedural programming. Same in C++.
If you want to do some object-oriented programming you can create objects:

$c = new MyClass;

Quoted text here. Click to load it

You don't need to include files if you just use built-in functions or
You can however put your own functions/classes in separate files and include

include 'my_functions.php';

Quoted text here. Click to load it



Re: php functions

El 02/06/2010 20:37, Jung, William escribió/wrote:
Quoted text here. Click to load it

PHP supports procedural programming, object-oriented programming and
whatever combination of both you are able to come with and built-in
functions are a reflection of this. Some (most?) of them offer
procedural style:

    $foo = strlen($bar);

Some of them offer object-oriented style:

    $foo = new SimpleXMLElement($bar);

And some of the offer *both*:


Apart from this, PHP does not have a clean concept of "library". All
available objects and functions are loaded into the global namespace.
You often "enable" and "disable" functionality by reconfiguring the
whole system so it loads or doesn't load the specific extension. You can
use function_exists() to guess whether an extension is loaded or not.
And you always need to be careful with your own code so you don't pick a
name that's already taken.

Yes, I know :)

-- - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web:
-- Mi web de humor satinado:

Site Timeline