本篇文章主要介紹了詳解PHP如何更好的利用PHPstorm的自動提示,具有一定的參考價值,有興趣的可以了解一下
##說明
class Data { public $name; public $gender; public $age; public function __construct($name,$gender,$age) { $this->name = $name; $this->gender = $gender; $this->age = $age; } } class Test { public function run() { $data = [ new Data('张三','男',18), new Data('李四','男',14), new Data('王五','男',17), new Data('大姨妈','女',23), ]; } private function eachData($data) { foreach($data as $item) { echo $item->name.'=>'.$item->gender.'=>'.$item->age."\n"; } } } (new Test)->run();
cho $item->name.'=>'.$item->sex.'=>'.$item->age."\n";
#
class Data { public $name; public $gender; public $age; public function __construct($name,$gender,$age) { $this->name = $name; $this->sex = $gender; $this->age = $age; } } class Test { public function run() { $data = [ new Data('张三','男',18), new Data('李四','男',14), new Data('王五','男',17), new Data('大姨妈','女',23), ]; } /** * 遍历输出数据 * @param array $data */ private function eachData($data) { foreach($data as $item) { if($item instanceof Data) { echo $item->name.'=>'.$item->gender.'=>'.$item->age."\n"; } } } } (new Test)->run();
思考
以上是php利用PHPstorm的自動提示詳解的詳細內容。更多資訊請關注PHP中文網其他相關文章!