本文整理匯總了PHP中foo::mul方法的典型用法代碼示例。如果您正苦於以下問題:PHP foo::mul方法的具體用法?PHP foo::mul怎麽用?PHP foo::mul使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類foo
的用法示例。
在下文中一共展示了foo::mul方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: mul
echo "b = " . $this->b . "\n";
}
function mul()
{
return $this->a * $this->b;
}
}
class bar extends foo
{
public $c;
function display()
{
/* alternative display function for class bar */
echo "This is class bar\n";
echo "a = " . $this->a . "\n";
echo "b = " . $this->b . "\n";
echo "c = " . $this->c . "\n";
}
}
$foo1 = new foo();
$foo1->a = 2;
$foo1->b = 5;
$foo1->display();
echo $foo1->mul() . "\n";
echo "-----\n";
$bar1 = new bar();
$bar1->a = 4;
$bar1->b = 3;
$bar1->c = 12;
$bar1->display();
echo $bar1->mul() . "\n";
示例2: display
<?php
class foo
{
// a comment
var $a;
var $b;
function display()
{
echo "This is class foo<br />";
echo "a = " . $this->a . "<br />";
echo "b = {$this->b}<br />";
}
function mul()
{
return $this->a * $this->b;
}
}
$foo1 = new foo();
$foo1->a = 2;
$foo1->b = 5;
$foo1->display();
echo $foo1->mul() . "";