Web Hosting Talk







View Full Version : PHP Classes Question


Studio64
09-22-2002, 10:20 PM
I remember this function with another language but, I don't know the implementation in PHP and I can't find it on the site.

Essentially how do I reference the methods of the class without calling the instansiated variable name.

Instead of

$a = new Class();

$a->Method_One("hello");
$some_var = $a->Method_Two();
echo $a->Something;


You would execute like this (but, obviously not this :D)

$a = new Class();

use($a) // (Maybe with($a)?
{
Method_One("hello");
$some_var = Method_Two();
echo Something;
}


I'm sure one of yall OOP guys remembers what I'm talking about...

Is their a similar function in PHP?

choon
09-23-2002, 02:38 AM
Hi,

Yes, there is. Take a look at this page http://www.php.net/manual/en/language.oop.php

Hope this helps!

Kindest regards,
Choon

Studio64
09-23-2002, 04:38 PM
Originally posted by choon
Hi,

Yes, there is. Take a look at this page http://www.php.net/manual/en/language.oop.php

Hope this helps!

Kindest regards,
Choon

I looked through the page and the comments and couldn't find the answer? Can you copy and paste the relevant code from the page that you believe was the solution?

Was it the & (ampersand)?

Khaless
09-26-2002, 10:25 AM
& is passing by reference and what it allows u to do is allow you to allow the function to modify its arguments... take this example.. for example :P

function addtoo(&$string)
{
$string.=" Adding some more";
}

$string="this is a string";
addtoo($string);

echo $string; // this will echo 'this is a string Adding some more'
yeah im pretty sure u get that i think if i can find the page on PHP .net it will give u more info

Khaless
09-26-2002, 10:26 AM
http://www.php.net/manual/en/functions.arguments.php <<-- there