本文整理汇总了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");
}
示例2: foo
function foo()
{
global $root;
//if ($result)
if ($row = $db->sql_fetchrow($result)) {
include $root . 'test113c.php';
$f = new MyClass();
$f->bar();
}
}
示例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));
}
示例4: conditionallyPluralize
public static function conditionallyPluralize($string, $count)
{
if (intval($count) !== 0) {
return MyClass::pluralize($string);
}
return $string;
}
示例5: printHello
function printHello()
{
MyClass::printHello();
print "MyClass2::printHello() " . $this->Hello;
print "MyClass2::printHello() " . $this->Bar;
print "MyClass2::printHello() " . $this->Foo;
}
示例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;
}
示例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 */
}
示例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);
}
示例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();
}
}
示例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>
示例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();
示例12: loadCode
<?php
class MyClass
{
public static function loadCode($p)
{
return include $p;
}
}
MyClass::loadCode('file-which-does-not-exist-on-purpose.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
示例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();
示例15: MyClass
<?php
require 'MyClass.php';
$myClass = new MyClass();
echo $myClass->hello();