提交 766f17a4 编写于 作者: Y yuenblue

Merge branch 'master' of gitcode.net:yuencczzy/phpdemo

<?php
function prinln(string $str) {
print $str;
print "\r\n";
}
class ATest {
public $aa='aaaa';
public function say()
{
print "Segmentfault {$this->aa} \n";
}
public function callSelf()
{
self::say();
}
public function callStatic()
{
static::say();
}
function callselfa() {
$this->say();
}
}
class BTest extends ATest {
public function say()
{
print "PHP {$this->aa} \r\n";
}
}
$b = new BTest();
$b->say(); // output: php:say方法被子类覆盖了所以输出PHP
$b->callSelf(); // output: segmentfault:继承的是父类的方法和属性
$b->callStatic(); // output: php
$b->callselfa();
......@@ -4,7 +4,7 @@ declare (strict_types = 1);
namespace app;
use think\Service;
use think\facade\Event;
/**
* 应用服务类
*/
......@@ -13,6 +13,11 @@ class AppService extends Service
public function register()
{
// 服务注册
// $this->app->bind()
Event::listen('UserLogin', function($user) {
print "????";
});
}
public function boot()
......
......@@ -2,6 +2,7 @@
namespace app\controller;
use app\BaseController;
use think\facade\Event;
use think\facade\Route;
class Index extends BaseController
......@@ -13,6 +14,7 @@ class Index extends BaseController
public function hello($name = 'ThinkPHP6')
{
Event::trigger("UserLogin","aaaa");
var_dump($this->request);
return Route::buildUrl('aaaa',['name'=>$name])->__toString();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册