Posted by C. on 06/15/07 21:10
On 15 Jun, 15:57, pelon <pelonbiol...@gmail.com> wrote:
> Hey!
>
> I'm new to OO in PHP but somewhat familiar with this paridigm in
> JAVA....
>
> So I was wondering if it is possible to have within a PHP script
> something equivalent to a main method as it is possible in JAVA....
>
First thing is the PHP, unlike Java has first class functions. Second
thing, is that PHP, like most scripting languages has an implicit
entry point at the beginning of the invoked file so all you need to do
is this:
BOF>>>>>>>>>>>
<?php
$obj = new myclass();
class myclass{
//my class's code
}
?>
<<<<<<<<<<<EOF
Although its generally considered neater to put class definitions in
their own include file so...
BOF>>>>>>>>>>>
<?php
require_once('myclass.inc.php');
$obj = new myclass();
?>
<<<<<<<<<<<EOF
HTH
C.
[Back to original message]
|