Hi ervrybody!
this function help to you, for don't need to include file manualy..
step 1:
in:
"cli_longrun_example_bosh.php"
after "<?php"
paste this:
[code]
function __autoload($class_name)
{
$class_name = implode("/", explode("_", $class_name));
echo $class_name;
require_once $class_name . '.php';
}
[/code]
-----------------------------
step 2:
in
XMPPHP/XMPP.php
change this (at line 122):
$this->roster = new Roster();
to this:
$this->roster = new XMPPHP_Roster();
in
XMPPHP/Roster.php
change this (at line 41):
class Roster {
to rhis:
class XMPPHP_Roster {
-----------------------------
step 3:
delete or comment out this:
in cli_longrun_example_bosh.php (line 19)
include 'XMPPHP/XMPP.php';
in XMPPHP/XMPP.php (line 30, 31)
require_once dirname(__FILE__) . "/XMLStream.php";
require_once dirname(__FILE__) . "/Roster.php";
in XMPPHP/XMLStrem.php (line 30 33 36)
require_once dirname(__FILE__) . '/Exception.php';
require_once dirname(__FILE__) . '/XMLObj.php';
require_once dirname(__FILE__) . '/Log.php';
-----------------------------
and it's works!!!
how does it works?
in step 1 we make the function what is run evry time when we make a new
object (example: $foo = new Bar;)
the object name is a paramater
(example:
$foo = new Bar;
means:
__autoload("Bar");
$foo = new Bar;
after the explode function make change _ to / (i know i can use str_replace
but i like this way because it is better if we make more complateted
autoload function)
and we open this "string" and .php
example:
"Foo_Bar_Class" -> "Foo/Bar/Class.php"
so if you build you path struture corect and you class name is correct this
function can save a lot of energy for you :)
i hope i can help you guys!
ps: sorry for my english
Original issue reported on code.google.com by errat...@gmail.com on 22 Oct 2009 at 7:43
Original issue reported on code.google.com by
errat...@gmail.com
on 22 Oct 2009 at 7:43