該函數返回url:<?php get_theme_url(); ?>
。我怎樣才能使用它作爲變量?PHP。如何使用函數結果作爲變量?
我試過這個代碼,但它不工作:
<?php
$a = get_theme_url();
$files = glob('$a/tariffs/tariff-b*.php');
foreach($files as $file) {
include($file);
echo $tariff_about;
?>
更新:
謝謝!我會用雙引號。
但現在都<?php get_theme_url(); ?>
和
<?php
$a = get_theme_url();
$files = glob($a."/tariffs/tariff-b*.php");
foreach($files as $file) { include($file);
echo $tariff_about; }
?>
回報只是http://localhost/
。
它可能是什麼?
你錯過了你的右括號上的foreach –
單引號不proccess的變量。使用雙引號。 –
請參閱PHP手冊中的[本頁](http://php.net/manual/en/language.types.string.php#language.types.string.parsing) – megaflop