在PHP中定义了一个执行运算符。在反引号(``)中的字符串被视为DOS命令(在UNIX/Linux中为shell命令),并返回其输出。该运算符的操作类似于PHP中的shell_exec()函数。
以下代码执行DIR命令并将结果作为字符串返回。
<?php $list=`dir *.php`; echo "$list"; ?>
将显示以下结果
Volume in drive C is Windows 10 Volume Serial Number is 540D-CE99 Directory of C:\xampp\php 01/27/2016 05:32 PM 18,869 CompatInfo.php 07/08/2020 06:40 PM 64 test.php 07/11/2020 02:13 PM 48 testscript.php 03/30/2013 05:59 PM 1,447 webdriver-test-example.php 4 File(s) 20,428 bytes 0 Dir(s) 178,002,157,568 bytes free
这是另一个反引号运算符的示例。它执行type命令
立即学习“PHP免费学习笔记(深入)”;
<?php $list='type testscript.php'; echo "$list"; ?>
将显示以下结果
type testscript.php
以上就是PHP执行操作符的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号