回声中的PHP语句

问题描述 投票:0回答:3

我基本上试图结合PHP语句。

<?php echo ROOT_PATH; ?>
<?php echo file_get_contents( "../css/themes/subtitle.php"); ?>

我希望实现这样的目标:

<?php echo file_get_contents( "ROOT_PATH/css/themes/subtitle.php"); ?> 
php echo file-get-contents
3个回答
0
投票

它非常简单,您可以将其更改为以下

//full path of the file 
$file_name = ROOT_PATH."/css/themes/subtitle.php";
echo file_get_contents($file_name);

它应该工作


2
投票

如果在单引号或双引号内调用常量,则它将始终作为字符串选取。

你需要添加如下:

<?php echo file_get_contents( ROOT_PATH."/css/themes/subtitle.php"); ?> 

0
投票

.运算符用于连接。

喜欢:

$str = "Hello";
echo $str;
echo "World";

可写成

$str = "Hello";
echo $str."World";
© www.soinside.com 2019 - 2024. All rights reserved.