English 中文(简体)
采用避孕药:通过论点
原标题:Using exec() in PHP: Passing arguments
  • 时间:2011-08-01 19:56:33
  •  标签:
  • php
  • exec
  • argv

为了测试的目的,请说投入。 PHP看着这一点。

<?php
{
$TO = "joe@net.net";
$FROM = "bob@net.net";
$SUB = "Yadda";
$BODY = "This is a test";
exec("/usr/bin/php /xxx.yyy.net/TESTS/sendit.PHP $TO $SUB $BODY $FROM > /dev/null &");
echo "DONE";
}
?>

以及派遣国。 PHP, 前线呼吁这样做。

<?php
$to      = $argv[1];
$subject = $argv[2];
$message = $argv[3];
$headers =  From:  .$argv[4]. "
" .
 Reply-To:  .$argv[4]. "
" .
 X-Mailer: PHP/  . phpversion();

mail($to, $subject, $message, $headers);
?>

当我公开投入时。 我的浏览器有PHP,我收到了回响的DONE电文,但测试电子邮件没有发出。 我的法典有什么错误? 谢谢。

最佳回答

在没有错误信息的情况下,我不敢肯定,如果这是整个问题,但我开始这样做:

<代码>argv改为“空间划界”。 The following Code:

 /usr/bin/php /xxx.yyy.net/TESTS/sendit.PHP $TO $SUB $BODY $FROM > /dev/null &

例如:

 /usr/bin/php /xxx.yyy.net/TESTS/sendit.PHP joe@net.net Yadda This is a test bob@net.net > /dev/null &

因此,$argv[3] == www.un.org/spanish/ga/president

问题回答

Without any debugging I don t think anyone will be able to give you an answer.

你们必须记住,*nix是敏感的。 因此,你必须确保xxx.yyyy.net/TESTS。 等等实际上都是正确的,是正确的

我也建议不向<代码>dev/null<>/code>发送任何材料,并可能寄至档案。 简单地说,/usr/bin/php 它可以使用不同的信条(以前向我申请),而且当我用信打字时,它会像想象的那样从事工作。

你们需要找到更多的信息! 检查实验室记录,看看这些文字在你从终端站运行时给你什么。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...