當前位置: 首頁>>代碼示例>>PHP>>正文


PHP MyClass類代碼示例

本文整理匯總了PHP中MyClass的典型用法代碼示例。如果您正苦於以下問題:PHP MyClass類的具體用法?PHP MyClass怎麽用?PHP MyClass使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了MyClass類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的MyClass類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。