【问题标题】:Show variable as a text in php在php中将变量显示为文本
【发布时间】:2018-11-20 13:38:59
【问题描述】:

我无法在 PHP 中显示文本 ip4=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1)

$shpmtaserver .= "ip4=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1)" . "\n";

有什么想法吗?

【问题讨论】:

  • 您发布的代码除了附加到字符串之外什么都不做,但它至少应该正确地做到这一点。您到底希望发生什么?

标签: php shell


【解决方案1】:

尝试删除.= 前面的.。您可以使用它附加到现有变量。

下面的代码应该可以正常工作。

$shpmtaserver = "ip4=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1)" . "\n";

echo $shpmtaserver;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-05
    • 1970-01-01
    • 1970-01-01
    • 2016-07-22
    • 2012-04-20
    相关资源
    最近更新 更多