本文整理汇总了PHP中Foo::setY方法的典型用法代码示例。如果您正苦于以下问题:PHP Foo::setY方法的具体用法?PHP Foo::setY怎么用?PHP Foo::setY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Foo
的用法示例。
在下文中一共展示了Foo::setY方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
function main()
{
$k = new Foo("something");
echo $k->getX();
echo "\n";
$k->setX("foo");
echo $k->getX();
echo "\n";
$k->setXVerified("string");
echo $k->getX();
echo "\n";
$k->setY(new Bar());
}
示例2: Foo
</head>
<body>
<?php
// Some simple OOP in PHP.
if (isset($theFoo)) {
echo "Object ", $theFoo, " has been restored <br/>";
} else {
// Creating a new object looks a lot like Java
$fooVar = new Foo(77, 88, 99);
// When using the object in a String context, the "magic" toString()
// method will implicitly be called. See Foo.php.
echo "fooVar is ", $fooVar, "<br/>";
// Unlike Java (but like C++) we use the arrow notation rather than the
// "dot" notation to access methods and data within an object
$fooVar->setX(70);
$fooVar->setY(80);
// Since z is public, we can access it directly if we wish
$fooVar->z = 90;
echo "fooVar is ", $fooVar, "<br/>";
$subFooVar = new SubFoo(22, 33, 44, 55);
echo "subFooVar is ", $subFooVar, "<br/>";
// We can access setX and setY via inheritance
$subFooVar->setX(20);
$subFooVar->setY(30);
$subFooVar->z = 40;
$subFooVar->setSub(50);
echo "subFooVar is ", $subFooVar, "<br/>";
echo "x field is " . $subFooVar->subGetX() . "<br/>";
echo "y field is " . $subFooVar->subGetY() . "<br/>";
echo "<br/>";
// "Kind of" polymorphic access. Note that we are mixing a subclass