note 118395 deleted from book.exec by peehaa

From: Date: Sun, 28 Apr 2019 10:22:19 +0000
Subject: note 118395 deleted from book.exec by peehaa
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-210768@lists.php.net to get a copy of this message
Note Submitter: ohcc at 163 dot com ---- You can use a pair of backquotes `` to run system commands. <?php header('Content-Type: text/html; charset=gbk'); echo ping -n 1 www.51-n.com;// on windows only ?> it returns the whole output of the command called as a string. Variables, class properties and return values of class methods between two ` signs will be replaced with their values. <?php header('Content-Type: text/html; charset=gbk'); $domain = 'www.51-n.com'; echo ping -n 1 {$domain}; ?> <?php header('Content-Type: text/html; charset=gbk'); class Ping { private $domain; private $count; public function setDomain($domain){ $this->domain = $domain; } public function setCount($count){ $this->count = $count; } public function getDomain(){ return $this->domain; } public function ping(){ return ping -n {$this->count} {$this->getDomain()}; } } $p = new Ping; $p->setDomain('www.wuxiancheng.cn'); $p->setCount(1); echo $p->ping(); ?>

« previous php.notes (#210768) next »