* Sorry, I am learning English now and my English is still not so good. Please understand my situation.
As far as I know, Static is required to use like Class::Function(params);
Like this one.
class Foo {
static function Bar($msg){
echo $msg;
}
}
There is one file in XE(is CMS developed in Korea).
(XE Official Site : http://www.xpressengine.com/?l=en)
Of course, This is a summary of real file
<?php
/**
* Manages Context such as request arguments/environment variables
* It has dual method structure, easy-to use methods which can be called as self::methodname(),and methods called with static object.
*/
class Context
{
/**
* codes after <body>
* @var string
*/
public $body_header = NULL;
/**
* returns static context object (Singleton). It's to use Context without declaration of an object
*
* @return object Instance
*/
function &getInstance()
{
static $theInstance = null;
if(!$theInstance)
{
$theInstance = new Context();
}
return $theInstance;
}
/**
* Add html code after <body>
*
* @param string $header Add html code after <body>
*/
function addBodyHeader($header)
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
$self->body_header .= "
" . $header;
}
}
This is the comment at the top of this file.
It has dual method structure, easy-to use methods which can be called as self::methodname(),and methods called with static object.
In this comment, It can use Class::Function() and I have been using in XE.
But it don't tell how they make. How can I make like it?
Edit1 :
The file's name is Context.class.php and It is included in other files.
<?php
require(_XE_PATH_ . 'classes/context/Context.class.php');
Context::addBodyHeader("Some Codes");
?>