当前位置: 首页>>代码示例>>PHP>>正文


PHP Foo::setY方法代码示例

本文整理汇总了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());
}
开发者ID:badlamer,项目名称:hhvm,代码行数:13,代码来源:setter.php

示例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
开发者ID:bosstweed11,项目名称:school,代码行数:31,代码来源:ex19.php


注:本文中的Foo::setY方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。