Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php为html获取价值_Php_Html - Fatal编程技术网

php为html获取价值

php为html获取价值,php,html,Php,Html,我举了以下例子: 我在config\resources.php中有一个值数组-例如: <?php define('resrc', array( 'logo' => 'src/images/logo.png', 'bscss' => 'src/bootstrap.css', 'bsthcss' => 'src/bootstrap-theme.css', 'bsjs' => 'src/js/boot

我举了以下例子:

我在config\resources.php中有一个值数组-例如:

<?php
    define('resrc', array(
        'logo' => 'src/images/logo.png',
        'bscss' => 'src/bootstrap.css',
        'bsthcss' => 'src/bootstrap-theme.css',
        'bsjs' => 'src/js/bootstrap.js',
        'chset' => 'utf-8',
        'jquery' => '/src/jquery/jquery_1.12.4_min.js',
        )
    );
?>

现在在structure\head.php中,我有如下内容:

<?php
require('config/resources.php');
class Head {
    public static $head;
    public static function renderHeadTag() {

        $head = "<head>";
        $head .= "<meta charset=".$resrc['chset'].">";
        $head .= "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">";
        $head .= "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">";

        $head .= "</head>";

        return $head;
    }
}
?>

但我仍然无法得到数组的值。我很久没有做过这样的事了。有人能给点提示吗?

您正在使用数组

调用常量不能以美元符号作为前缀

这一行:

$head .= "<meta charset=".$resrc['chset'].">";
$head.=”;
应如下所示:

$head .= "<meta charset=".resrc['chset'].">";
$head.=”;
p.S.常量按照一些命名惯例,最好(不是必须)用大写字母命名常量,
RESRC
例如

非常感谢:)看起来好像是很长时间了:p