小编Jon*_*itt的帖子

从命令行执行时,如何阻止PHP返回标头?

这可能是一个荒谬的问题,但它一直困扰着我.我有一个邮件转发器管道传输到PHP脚本,它收到完美,但我有以下错误邮寄给我立即:

A message that you sent could not be delivered to one or more of its recipients. This is a permanent error. The following address(es) failed:

  pipe to |/home/[webroot]/public_html/external/mobile/email.php
    generated by mobile@[mydomain]

The following text was generated during the delivery attempt:

X-Powered-By: PHP/5.2.13 
Content-type: text/html
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,Exim认为标题响应是我脚本的错误.该脚本可以完美地从php:// stdin接收电子邮件,但Exim快速回复错误.

加,

  • 它是从控制台运行的,而不是Apache,所以HTAccess或配置Apache很可能什么都不做.
  • 我找不到任何解决方案,或任何有同样问题的人.

所以我的问题是:如何摆脱这两个标题?

谢谢,〜强尼

编辑,来源:

    #!/usr/bin/php
<?php
    $fd = fopen("php://stdin", "r");
        $email = "";
        while (!feof($fd)) {
         $email .= fread($fd, 1024);
        }
        fclose($fd);

        $dat = fopen(dirname(__FILE__).'/test.txt', 'w');
        fwrite($dat, $email);
        fclose($dat);
Run Code Online (Sandbox Code Playgroud)

php email command-line exim pipe

6
推荐指数
1
解决办法
4774
查看次数

使用正则表达式从PHP中解析字符串中的函数

有没有一种逻辑方法可以在PHP中使用正则表达式去掉函数名称及其参数?目前我将它逐行拆分,这样我就可以在每一行上使用每个函数以便于标记.

所以:

doSomeFunction(arg, moreargs, stuff);
breakSomething();
ini_set(include_path, /home/htdocs/);
Run Code Online (Sandbox Code Playgroud)

array([0] => 'doSomeFunction(arg, moreargs, stuff);', [1] => 'breakSomething();' and so on...
Run Code Online (Sandbox Code Playgroud)

我遇到的真正问题是使用正则表达式获取函数名称具有如下语法:

$functionfromregex($args);
Run Code Online (Sandbox Code Playgroud)

这些函数是使用PHP的"变量函数名"功能构建的,因此它是可行的.参数被作为数组使用,因为没有合理的方法来粘合它们以收集PHP需要解析它们的方式.真正的缺点是我对正则表达式不太熟悉,任何帮助将不胜感激,如果您需要任何其他信息,请随时询问.

php regex parsing function

3
推荐指数
1
解决办法
1077
查看次数

标签 统计

php ×2

command-line ×1

email ×1

exim ×1

function ×1

parsing ×1

pipe ×1

regex ×1