Given the following classes:
<?php
class test{
static public function statfunc()
{
echo "this is the static function<br/>";
$api= new object;
}
}
class traductor
{
public function display()
{
echo "this is the object function";
}
}
test::statfunc();
$api->display();
This does not display the message "this is the static function<br/>".
Is there a way to instantiate through a static function and get that object outside?
Thanks… I am inexperienced regarding object programming code.
You should return the object from your static function:
And then store the returned object in a variable that you can use.