本文整理汇总了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() . "";