Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: Problem in PHP 5
03-16-2010, 06:21 AM #1
- Join Date
- Mar 2010
- Thanked 0 Times in 0 Posts
Problem in PHP 5
I wanted to know how to call a function which is present in a class in 1 file from a class in another file. Please help ASAP. I am using PHP 5...
Thank you guys
03-16-2010, 03:30 PM #2
- Join Date
- Sep 2002
- Saskatoon, Saskatchewan
- Thanked 2,662 Times in 2,631 Posts
Statically I presume?
Depending on you're version of PHP depends on how you get it in there though. The end result is always an include/require call against you're other class file, but in 5.3.x+ you can chain it against the spl_autoload method to import using the use keyword.Code:MyOtherClass::method();
Now if you mean that this is an Object method, then you'll need to either pass an instance of an object, create a singleton object for instantiation, or globalize you're object (not recommended).PHP Code:
// Or, using spl_autoload if registered directly, include the autoload file and call:
use /path/to/MyOtherClass AS MyOtherClass; // Where MyOtherClass is in namespace /path/to
public function __construct()
Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)PHP Code:
header('HTTP/1.1 420 Enhance Your Calm');