I was wondering where functions and classes are defined for php...
I remember looking at WordPress source, and they were calling functions without including files, so I'm curious where this stuff is defined.
What I'm looking at doing putting some connection code, like mysql or like for twilio below
require "sms/Twilio.php";
$AccountSid = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
$AuthToken = "BBBBBBBBBBBBBBBBBBBBBBBBBBBBB";
$client = new Services_Twilio($AccountSid, $AuthToken);
I'm then thinking of putting just this in a file and including it in many places, but I'm curi开发者_JAVA百科ous if it can get easier than including a file.
You can use __autoload
See http://www.php.net/__autoload
As you're using PHP5, it's best to use spl_autoload_register()
It allows you to assign multiple autoloader methods/functions, but otherwise works in much the same way as __autoload()
.
精彩评论