• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP MyClass类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中MyClass的典型用法代码示例。如果您正苦于以下问题:PHP MyClass类的具体用法?PHP MyClass怎么用?PHP MyClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了MyClass类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: testHalfNegativeUneven

 public function testHalfNegativeUneven()
 {
     $c = new MyClass();
     $var1 = -5;
     $result = $c->half($var1);
     $expectedResult = -2.5;
     $this->assertEquals($expectedResult, $result, "The half of -5 should be -2.5");
 }
开发者ID:BrobakS,项目名称:phpTest,代码行数:8,代码来源:MyClassTest.php


示例2: foo

function foo()
{
    global $root;
    //if ($result)
    if ($row = $db->sql_fetchrow($result)) {
        include $root . 'test113c.php';
        $f = new MyClass();
        $f->bar();
    }
}
开发者ID:9Yg1rxeSeha90ZU1,项目名称:pixy,代码行数:10,代码来源:test113b.php


示例3: testBasic

 function testBasic()
 {
     $o = new MyClass();
     $o->prop1 = "hej";
     $o->prop2 = '';
     // verify empty props are not shown
     $o->prop3 = "hallå";
     $o->setPrivProp("bah");
     // verify private props are not shown
     $this->assertEquals("prop1: hej\n" . "prop3: hallå", \Core3\Helper\Object::describePropertiesWithValues($o));
 }
开发者ID:martinlindhe,项目名称:core3,代码行数:11,代码来源:ObjectTest.php


示例4: conditionallyPluralize

 public static function conditionallyPluralize($string, $count)
 {
     if (intval($count) !== 0) {
         return MyClass::pluralize($string);
     }
     return $string;
 }
开发者ID:carriercomm,项目名称:Sipen-CMS,代码行数:7,代码来源:inflect.class.php


示例5: printHello

 function printHello()
 {
     MyClass::printHello();
     print "MyClass2::printHello() " . $this->Hello;
     print "MyClass2::printHello() " . $this->Bar;
     print "MyClass2::printHello() " . $this->Foo;
 }
开发者ID:SandyS1,项目名称:presentations,代码行数:7,代码来源:privateprotected.php


示例6: csvHandler

 public function csvHandler(GearmanJob $job)
 {
     $mass = unserialize($job->workload());
     self::$count = count($mass[1]) - 1;
     usort($mass, array('MyClass', 'cmp'));
     $off = array_slice($mass, 0, 1000);
     self::$collection[] = $off;
 }
开发者ID:nycmic,项目名称:csv,代码行数:8,代码来源:myClass.php


示例7: printHello

 function printHello()
 {
     MyClass::printHello();
     print "MyClass2::printHello() " . $this->public;
     print "MyClass2::printHello() " . $this->protected;
     print "MyClass2::printHello() " . $this->protected2;
     /* Will result in a Fatal Error: */
     //print "MyClass2::printHello() " . $this->private; /* Fatal Error */
 }
开发者ID:dw4dev,项目名称:Phalanger,代码行数:9,代码来源:test136.php


示例8: testMockingClassMethod

 public function testMockingClassMethod()
 {
     $this->initAspectMock();
     //$mock = \AspectMock\Test::double(MyClass::class, ['myClassMethod' => 'a']);
     $mock = \AspectMock\Test::double('MyClass', ['myClassMethod' => 'a']);
     //$mock = \AspectMock\Test::double('\MyClass', ['myClassMethod' => 'a']);
     $classMethodReturned = MyClass::myClassMethod();
     // Extra verification to see if the AspectMock double is actually being run yet:
     //$mock->verifyInvoked('myClassMethod');
     $this->assertEquals('a', $classMethodReturned);
 }
开发者ID:samsonasik,项目名称:AspectMock-test,代码行数:11,代码来源:MyClassTest.php


示例9: actionDefault

 function actionDefault()
 {
     // Create new instance of MyClass and execute test()
     $my = new MyClass();
     $res = $my->test();
     // Check for errors
     while ($err = YDError::catchError($res)) {
         YDDebugUtil::dump($err, '$err');
         $err->level;
         // 3
         $err->name;
         // fatal
         $err->message;
         // We couldn't do something
         $err->file;
         // ..../MyClass.php
         $err->line;
         // x
     }
     // We can also set automatic reporting
     YDError::reporting(YD_ERROR_FATAL);
     // display fatals, warnings and notices
     YDError::reporting(YD_ERROR_WARNING);
     // display warnings and notices
     YDError::reporting(YD_ERROR_NOTICE);
     // display notices
     YDError::reporting(YD_ERROR_NONE);
     // don't display errors
     // We can get the last errors array
     $errors = YDError::getAll();
     YDDebugUtil::dump($errors, '$errors');
     // Or we could dump the error
     if ($err = YDError::catchError($res)) {
         $err->dump();
     }
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:36,代码来源:error.php


示例10: h

        echo '<p>渡されたデータはnullでした。</p>';
        return;
    }
    // 渡されたデータの内容を表示する
    echo '<p>渡されたデータ内容を表示する:</p>';
    echo '<ul>';
    echo '<li>id: ' . h($data->id) . '</li>';
    echo '<li>text: ' . h($data->text) . '</li>';
    echo '</ul>';
}
// MyData型のオブジェクトを生成する
$data = new MyData();
$data->id = 1;
$data->text = '今日は雨が降っています。';
// MyClassのインスタンスを作成し、MyData型のオブジェクトをセットする
$myclass = new MyClass();
$myclass->setData($data);
// show_data_details()関数に、MyData型のオブジェクトを渡す
echo '<p>show_data_details()関数に$dataを渡した場合:</p>';
show_data_details($data);
// show_data_details()関数に、nullを渡す
echo '<p>show_data_details()関数にnullを渡した場合:</p>';
show_data_details(null);
function h($string)
{
    return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
}
?>
</div>
</body>
</html>
开发者ID:sxyr318,项目名称:study_php,代码行数:31,代码来源:164_type_hinting.php


示例11: MyProtected

    protected function MyProtected()
    {
    }
    // Объявление закрытого метода
    private function MyPrivate()
    {
    }
    // Это общедоступный метод
    function Foo()
    {
        $this->MyPublic();
        $this->MyProtected();
        $this->MyPrivate();
    }
}
$myclass = new MyClass();
$myclass->MyPublic();
// Работает
//$myclass->MyProtected(); // Неисправимая ошибка
// $myclass->MyPrivate(); // Неисправимая ошибка
$myclass->Foo();
// Работает общий, защищенный и закрытый
/**
 * Определение MyClass2
 */
class MyClass2 extends MyClass
{
    // Это общедоступный метод
    function Foo2()
    {
        $this->MyPublic();
开发者ID:AntonBeletsky,项目名称:LearnPHPdocs,代码行数:31,代码来源:Visibility.php


示例12: loadCode

<?php

class MyClass
{
    public static function loadCode($p)
    {
        return include $p;
    }
}
MyClass::loadCode('file-which-does-not-exist-on-purpose.php');
开发者ID:badlamer,项目名称:hhvm,代码行数:10,代码来源:bug43958.php


示例13: error_reporting

Aliasing on conflicting method should not cover up conflict.
--FILE--
<?php 
error_reporting(E_ALL);
trait Hello
{
    public function sayHello()
    {
        echo 'Hello';
    }
}
trait World
{
    public function sayHello()
    {
        echo ' World!';
    }
}
class MyClass
{
    use Hello, World {
        sayHello as sayWorld;
    }
}
$o = new MyClass();
$o->sayHello();
$o->sayWorld();
?>
--EXPECTF--

Fatal error: Trait method 'sayHello' has not been applied, because there are collision in 'World' and 'Hello' traits on MyClass in %s on line %d, position %d
开发者ID:lihuibin,项目名称:jphp,代码行数:31,代码来源:language011.php


示例14: doWork

<?php

require '../vendor/autoload.php';
class MyClass
{
    use \atk4\core\HookTrait;
    public function doWork()
    {
        $this->hook('beforeWork');
        echo "Doing work\n";
        $this->hook('afterWork');
    }
}
$c = new MyClass();
$c->addHook('afterWork', function () {
    echo "HOOKed on work\n";
});
$c->doWork();
开发者ID:atk4,项目名称:core,代码行数:18,代码来源:test2.php


示例15: MyClass

<?php

require 'MyClass.php';
$myClass = new MyClass();
echo $myClass->hello();
开发者ID:goCavs,项目名称:MyPHPEvaluation,代码行数:5,代码来源:index.php


示例16: iterateVisible

<?php

#Example #1 Simple Object Iteration
class MyClass
{
    public $var1 = 'value 1';
    public $var2 = 'value 2';
    public $var3 = 'value 3';
    protected $protected = 'protected var';
    private $private = 'private var';
    function iterateVisible()
    {
        echo "MyClass::iterateVisible:\n";
        foreach ($this as $key => $value) {
            print "{$key} => {$value} " . PHP_EOL;
        }
    }
}
$class = new MyClass();
foreach ($class as $key => $value) {
    print "{$key} => {$value}" . PHP_EOL;
}
echo "\n";
$class->iterateVisible();
?>
 
开发者ID:jestintab,项目名称:zendphp,代码行数:25,代码来源:class-object-iterator-exm1.php


示例17: __construct

/**
 *  cppclassinphp.php
 *  @author Jasper van Eck<[email protected]>
 * 
 *  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;
开发者ID:sdgdsffdsfff,项目名称:PHP-CPP,代码行数:31,代码来源:cppclassinphp.php


示例18: setProperty

-->
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <?php 
class MyClass
{
    public $prop1 = "I'm a class property!";
    public function setProperty($newval)
    {
        $this->prop1 = $newval;
    }
    public function getProperty()
    {
        return $this->prop1 . "<br />";
    }
}
$obj = new MyClass();
echo $obj->getProperty();
// Get the property value
$obj->setProperty("I'm a new property value!");
// Set a new one
echo $obj->getProperty();
// Read it out again to show the change
?>
    </body>
</html>
开发者ID:shubhomedia,项目名称:bitm_php,代码行数:30,代码来源:simple_class_file4.php


示例19: showConstant

<?php

#Example #1 Defining and using a constant
class MyClass
{
    const CONSTANT = 'constant value';
    function showConstant()
    {
        echo self::CONSTANT . "\n";
    }
}
echo MyClass::CONSTANT . "\n";
$classname = "MyClass";
echo $classname::CONSTANT . "\n";
// As of PHP 5.3.0
$class = new MyClass();
$class->showConstant();
echo $class::CONSTANT . "\n";
// As of PHP 5.3.0
开发者ID:jestintab,项目名称:zendphp,代码行数:19,代码来源:class-const-1.php


示例20: printHello

 public function printHello()
 {
     MyClass::printHello();
     /* Should print */
     print "MyClass2::printHello() " . $this->Hello;
     /* Shouldn't print out anything */
     print "MyClass2::printHello() " . $this->Bar;
     /* Shouldn't print (not declared)*/
     print "MyClass2::printHello() " . $this->Foo;
     /* Should print */
 }
开发者ID:nagyist,项目名称:KomodoEdit,代码行数:11,代码来源:php5_sample.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP MyController类代码示例发布时间:2022-05-23
下一篇:
PHP MyCakeTestCase类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap