本文整理汇总了PHP中MyClass::myMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP MyClass::myMethod方法的具体用法?PHP MyClass::myMethod怎么用?PHP MyClass::myMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyClass
的用法示例。
在下文中一共展示了MyClass::myMethod方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
echo __NAMESPACE__ . PHP_EOL;
// output namespace
echo __LINE__ . PHP_EOL;
// output file line number
class MyClass
{
public function __construct()
{
echo __CLASS__ . PHP_EOL;
}
public function myMethod()
{
echo __METHOD__ . PHP_EOL;
}
}
function myFunction()
{
echo __FUNCTION__ . PHP_EOL;
}
$myClass = new MyClass();
// output Classname
$myClass->myMethod();
// output Method
myFunction();
// output Function
}
namespace {
// Global
var_dump(__NAMESPACE__);
// output empty on Global Scope
}
示例2: __construct
* cppclassinphp.php
* @author Jasper van Eck<jasper.vaneck@copernica.com>
*
* An example file to show the working of using a C++ class in PHP.
*/
class TestClass
{
public $x = 1223;
public function __construct()
{
echo "TestClass::__construct\n";
}
}
//create a MyCustomClass object, which is an object of a C++ class
$object1 = new MyClass();
$object2 = $object1->myMethod(1);
$object2->myMethod(1);
echo "unset\n";
unset($object1);
echo "got here\n";
return;
//echo("prop x: ".$object1->x."\n");
$object1->x = 10;
$object1->y = 20;
echo "prop x: " . $object1->x . "\n";
echo "prop y: " . $object1->y . "\n";
$object2 = clone $object1;
echo "prop x: " . $object2->x . "\n";
echo "prop y: " . $object2->y . "\n";
return;
// run a function of the class
示例3: __construct
{
public function __construct()
{
var_dump('construct');
}
public function myMethod()
{
return 'myMethod()';
}
public function __destruct()
{
var_dump('destruct');
}
}
$oMyClass = new MyClass();
var_dump($oMyClass->myMethod());
class Person
{
private $name;
private $age;
private $id;
function __construct($name, $age)
{
$this->name = $name;
$this->age = $age;
}
function setId($id)
{
$this->id = $id;
}
function __destruct()