V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
alex321
V2EX  ›  PHP

workerman 定义 PHP 路径中存在空格要怎么搞

  •  
  •   alex321 · 2017-05-12 14:48:18 +08:00 · 2186 次点击
    这是一个创建于 2553 天前的主题,其中的信息可能已经有所发展或是发生改变。
    就是 C:\Program Files (x86)\PHP 这种情形,PHP 是 5.6.30。
    作为一个菜鸟,试了好多次就没成功。。之前写 Nginx+PHP+MySQL 控制脚本添加双引号就可以,现在不行。报 C:\Program 不是可执行…一类的错误。
    7 条回复    2017-05-18 17:44:26 +08:00
    anviod
        1
    anviod  
       2017-05-12 15:14:44 +08:00
    反斜杠 加 双引号 例如: "C:/Program Files (x86)/PHP"
    alex321
        2
    alex321  
    OP
       2017-05-12 16:45:23 +08:00
    @anviod 已经尝试过如下:

    $process= proc_open("\"C:\\Program Files (x86)\\PHP\\php.exe\" -c \"C:\\Program Files (x86)\\PHP\\php.ini\" \"$start_file\" -q", $descriptorspec, $pipes);

    $process= proc_open('"C:\\Program Files (x86)\\PHP\\php.exe" -c "C:\\Program Files (x86)\\PHP\\php.ini" "$start_file" -q', $descriptorspec, $pipes);

    $process= proc_open("C:\\Program Files (x86)\\PHP\\php.exe -c C:\\Program Files (x86)\\PHP\\php.ini \"$start_file\" -q", $descriptorspec, $pipes);

    $process= proc_open('"C:/Program Files (x86)/PHP/php.exe" -c "C:/Program Files (x86)/PHP/php.ini" "$start_file" -q', $descriptorspec, $pipes);

    均提'C:\Program' 不是内部或外部命令,也不是可运行的程序。。。。
    sbw
        3
    sbw  
       2017-05-12 17:16:39 +08:00   ❤️ 1
    这样呢
    C:\\Progra~2//PHP\\php.exe
    C::\\Program\ Files\ (x86)\\PHP\\php.exe
    alex321
        4
    alex321  
    OP
       2017-05-12 18:26:04 +08:00
    临时用了个过渡方法:

    $cmd = sprintf('%s "%s" -q', $ppath, $start_file);
    if(strtolower(substr(PHP_OS, 0, 3)) === 'win')$cmd = '"'.$cmd.'"';
    $process= proc_open($cmd, $descriptorspec, $pipes);

    但依旧会提示 'C:\Program',然而跑起来了。。。

    @sbw 提供的 C:\\Progra~2//PHP\\php.exe 方法和过渡方法处理结果一样。。。C::\\Program\ Files\ (x86)\\PHP\\php.exe 方法没有提示。
    mingyun
        5
    mingyun  
       2017-05-13 00:20:15 +08:00
    别折腾 php 换个路径吧
    anviod
        6
    anviod  
       2017-05-13 21:52:14 +08:00
    那你为何不设置 PHP 到系统环境变量?
    alex321
        7
    alex321  
    OP
       2017-05-18 17:44:26 +08:00
    @mingyun 路径我不能定。。。。。

    @anviod 环境变量我设置不能。。。。。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1069 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 22:10 · PVG 06:10 · LAX 15:10 · JFK 18:10
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.