PHP 错误:,
我正在尝试将此 php 代码作为 applescript 中的命令行运行。这是代码
"/usr/bin/php -r '($mac = 'gg:a2:gg:gg:gg:e6'; $porttemp = '9'; $ip ='255.255.255.255';
$mac_bytes = explode(\":\", $mac);
$mac_addr = \"\";
for ($i=0; $i<6; $i++)
$mac_addr .= chr(hexdec($mac_bytes[$i]));
$packet = \"\";
for ($i=0; $i<6; $i++) /*6x 0xFF*/
$packet .= chr(255);
for ($i=0; $i<16; $i++) /*16x MAC address*/
$packet .= $mac_addr;
$port = $porttemp;
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_set_option($sock, SOL_SOCKET, SO_BROADCAST, TRUE);
socket_sendto($sock, $packet, strlen($packet), 0, $ip, $port);
socket_close($sock);
)'"
语法在 applescript 编辑器上检查正常并且脚本运行但它弹出此错误:
结果: 错误“PHP 解析错误:语法错误,第 1 行命令行代码中出现意外的 ':'”编号 254
不确定问题是什么,但它是第一行 mac 地址中的 : 还是后面的 : ,而且,我尝试使用 : 来 \":\" 但也不起作用。知道出了什么问题吗?
I am trying to run this php code as a command line in applescript. here is the code
"/usr/bin/php -r '($mac = 'gg:a2:gg:gg:gg:e6'; $porttemp = '9'; $ip ='255.255.255.255';
$mac_bytes = explode(\":\", $mac);
$mac_addr = \"\";
for ($i=0; $i<6; $i++)
$mac_addr .= chr(hexdec($mac_bytes[$i]));
$packet = \"\";
for ($i=0; $i<6; $i++) /*6x 0xFF*/
$packet .= chr(255);
for ($i=0; $i<16; $i++) /*16x MAC address*/
$packet .= $mac_addr;
$port = $porttemp;
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_set_option($sock, SOL_SOCKET, SO_BROADCAST, TRUE);
socket_sendto($sock, $packet, strlen($packet), 0, $ip, $port);
socket_close($sock);
)'"
The syntax checks out fine on the applescript editor and the script runs but it pops this error:
Result:
error "PHP Parse error: syntax error, unexpected ':' in Command line code on line 1" number 254
not sure what the issue is but is it the : in the mac address in the first line or the : later and also, I tried \":\" with the :`s but that did not work either. Any idea whats wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
尝试这样的事情:
Try something like this instead: