Page 1 of 1

java classes in php

Posted: Mon Jun 16, 2008 2:32 am
by ismail
hi,
in java this is a syntax for creating an object for class.
hello obj=new hello();

where as in php this is the syntax.
$obj = new Java("hello");

now i want to cal constructor with parameters, here the syntax for java.
hello obj=new hello("key");

pls give syntax for the above in php.

thanks and regards.

Re: java classes in php

Posted: Mon Jun 16, 2008 3:02 am
by Ollie Saunders

Code: Select all

$variableNameForObject = new ClassName($parameters, $go, $here);
Also, there's a manual for this stuff.

Re: java classes in php

Posted: Mon Jun 16, 2008 3:19 am
by onion2k
ole wrote:Also, there's a manual for this stuff.
Indeed there is, and you didn't read it either. He's talking about PHP's Java built-in object, not a normal class. ;)

http://uk3.php.net/manual/en/java.examples.php

Code: Select all

$obj = new Java("hello", "parameter1", "parameter2", "parameter3");

Re: java classes in php

Posted: Mon Jun 16, 2008 3:23 am
by Ollie Saunders
Sorry ismail I misinterpreted what you were asking.
I'm not quite sure how to respond to you onion2k.

Re: java classes in php

Posted: Mon Jun 16, 2008 4:09 am
by Kieran Huggins
if PHP stays true to form, you could try the following syntax (untested, but worth a try):

Code: Select all

$obj = new Java( array("class_name", "constructor_argument") );