2013-03-24 38 views
1

我试图使用PHP Exec命令行将文本字符串作为变量传递,但整个文本未被传递。如何将文本字符串作为PHP Exec命令传递

的文字是这样的:

$title_page = 'Channel | This is the channels title'; 

那么EXEC行是:

exec("$path_to_php $emailer $article_sub_security_var $article_id > /dev/null &"); 

林检索它们是这样的:

$article_sub_security_var = $_SERVER['argv'][1]; 
$article_id = $_SERVER['argv'][2]; 
$page_title = $_SERVER['argv'][3]; 

命令行与正常工作$ page_title的例外。它只返回字符串的一部分,而不是全部。

任何建议,以完全赞赏通过它。

+1

我在您的exec声明中的任何地方都没有看到'$ title_page'或甚至$ page_title': -/ – Crisp 2013-03-24 16:03:00

+0

谨慎使用exec! – 2013-03-24 16:50:30

回答

1

命令行正常工作,但$ page_title除外。它只返回字符串的一部分,而不是全部。

我猜你的问题是在网页标题中|(管),请尝试使用$title_pageescapeshellcmd之前。

+0

对不起。该命令在其中包含$ page_title。我的错误。 darthmaim - 你能告诉我代码在$ page_title上的样子吗?它会进入exec命令行吗?所以像这样︰exec(“$ path_to_php $ emailer $ article_sub_security_var $ article_id escapeshellcmd($ page_title)>/dev/null &"); – Ruf1 2013-03-24 19:31:41

+0

我只是尝试使用escapeshellcmd($ page_title),但它does not工作。我试图删除管道,但它似乎只返回文本字符串的第一个单词,它似乎返回到第一个空格的任何文本。 – Ruf1 2013-03-24 21:00:12

+1

您必须在引号('“')中包含'$ page_title',因为它包含空格,就像这样:'exec(“$ path_to_php $ emailer $ article_sub_security_var $ article_id \”$ page_title \“>/dev/null &");' – darthmaim 2013-03-24 21:06:18

相关问题