java classes in php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ismail
Forum Newbie
Posts: 10
Joined: Thu Jun 05, 2008 11:51 pm

java classes in php

Post 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.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Re: java classes in php

Post by Ollie Saunders »

Code: Select all

$variableNameForObject = new ClassName($parameters, $go, $here);
Also, there's a manual for this stuff.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: java classes in php

Post 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");
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Re: java classes in php

Post by Ollie Saunders »

Sorry ismail I misinterpreted what you were asking.
I'm not quite sure how to respond to you onion2k.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Re: java classes in php

Post 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") );
Post Reply