6 Star 3 Fork 4

天择网络/天择云商

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
a.php 4.96 KB
一键复制 编辑 原始数据 按行查看 历史
[email protected] 提交于 2018-01-31 14:33 . 文件权限修改
<?php
try {
class A {
public function foo() {
echo '1';
}
}
A::has();
} catch (Exception $e) {
echo 'aaa';
// var_dump($e->getMessage());
// var_dump($e->getCode());
// var_dump($e->getLine());
// var_dump($e->getMessage());
}
exit;
class A {
public static function foo() {
echo '1';
static::who();
}
public static function who() {
echo __CLASS__."\n";
}
}
class B extends A {
public static function test() {
echo '2';
A::foo();
parent::foo();
self::foo();
}
public static function who() {
echo __CLASS__."\n";
}
}
class C extends B {
public static function who() {
echo '3';
echo __CLASS__."\n";
}
}
C::test();
exit;
class Dome1
{
private $var = array();
public function __construct()
{
echo "__construct1 <br>";
}
final public function OtherClassfind(Dome1 $array)
{
var_dump($array);
}
final public function arrayfind(array $array)
{
var_dump($array);
}
final public function Traversablefind(Traversable $array)
{
var_dump($array);
}
final public function callablefind(callable $array)
{
var_dump($array);
}
}
class foo
{
public $a = 1;
public $b = 1;
public $c = 1;
}
$a = new Dome2;
$c = new foo;
// $a->OtherClassfind([1,2]);
$a->OtherClassfind($a);
$a->arrayfind([1,2]);
$a->Traversablefind($a->arrayfind([1,2]));
// $a->arrayfind(22);
// $a->find(1);
exit;
class Dome1
{
private $var = array();
public function __construct()
{
echo "__construct1 <br>";
}
final public function find()
{
echo '1';
}
}
class Dome2 extends Dome1
{
private $var = array();
public function __construct()
{
echo "__construct2 <br>";
}
}
$a = new Dome2;
$a->find();
exit;
class MyIterator
{
private $var = array();
public function __construct()
{
echo "__construct <br>";
}
public function __set($name, $value) {
echo "__set $name = $value <br>";
$this->var[$name] = $value;
}
public function __get($name) {
echo "__get $name <br>";
var_dump( $this->var[$name]);
}
public function __isset($name) {
echo "__isset $name <br>";
var_dump( empty($this->var[$name]));
}
public function __unset($name) {
echo "__unset $name <br>";
// var_dump(unset($this->var[$name]));
unset($this->var[$name]);
}
public function __destruct() {
echo "__destruct <br>";
}
public function __call($name, $value) {
echo "__call $name = $value <br>";
echo '打断就不会报错';
var_dump($name);
var_dump($value);
}
public static function __callStatic($name, $value) {
echo "__callStatic $name = $value <br>";
var_dump($name);
var_dump($value);
}
public function __sleep() {
echo "__sleep <br>";
return ['var'];
}
public function __wakeup() {
echo "__wakeup <br>";
}
public function __toString() {
echo "__toString <br>";
return 'aaa';
}
public function __invoke( $name ) {
echo "__invoke $name <br>";
}
public static function __set_state( $name ) {
echo "__set_state <br>";
var_dump($name);
return '';
}
public function __clone() {
echo "__clone <br>";
}
}
function f($obj){
var_dump($obj);
}
$a = new MyIterator;
$a->b = 'c';
$a->c = 'd';
$a->d = 'e';
$a->e = 'f';
echo '---------------------------------------<br>';
$c = $a->b;
echo '---------------------------------------<br>';
echo $c;
echo '---------------------------------------<br>';
var_dump($a->b);
echo '---------------------------------------<br>';
empty($a->b);
echo '---------------------------------------<br>';
unset($a->b);
echo '---------------------------------------<br>';
unset($a->b);
echo '---------------------------------------<br>';
isset($a->b);
echo '---------------------------------------<br>';
empty($a->b);
echo '---------------------------------------<br>';
@$a->runTest('in object context');
echo '---------------------------------------<br>';
@$a::runTest('in object context');
echo '---------------------------------------<br>';
$d = serialize($a);
echo $d;
echo "<br>";
echo "<br>";
var_dump(unserialize($d));
echo '---------------------------------------<br>';
echo $a;
echo '---------------------------------------<br>';
$a('obj');
echo '---------------------------------------<br>';
$g = var_export($a, true);
var_dump($g);
eval('$b = ' . var_export($a, false) . ';');
echo '---------------------------------------<br>';
echo '---------------------------------------<br>';
echo '---------------------------------------<br>';
echo '---------------------------------------<br>';
echo '---------------------------------------<br>';
echo '---------------------------------------<br>';
echo '---------------------------------------<br>';
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/TianZeWangLuo/TianZeYunShang.git
[email protected]:TianZeWangLuo/TianZeYunShang.git
TianZeWangLuo
TianZeYunShang
天择云商
master

搜索帮助