繁体   English   中英

PHP内部的变量包括

[英]variables inside php include

您好,所以我无法使用包含项来与我的网站网址$IN_LIONIMAGES['siteurl'];因此它将是$IN_LIONIMAGES['siteurl']; 它不起作用,因此页眉,导航和页脚不会显示,因为它包含在其中。 我在做什么错。 所以说得不好。

PS它显示是否执行<?php echo $IN_LIONIMAGES['siteurl']; ?> <?php echo $IN_LIONIMAGES['siteurl']; ?>只要我不在其他PHP标记之外。 那是否意味着您可以在其他PHP标签中使用PHP标签? 如果可以,我正在尝试做些什么?

index.php

<?php
$IN_LIONIMAGES = include('config.php');
?>

<?php include_once $IN_LIONIMAGES['siteurl'] .'/inc/header.inc.php'; ?>
<?php include_once $IN_LIONIMAGES['siteurl'] .'/inc/nav.inc.php'; ?>

<body>


    <section class="hero">
        <div class="background-image" style="background-image: url(<?php echo URLpath; ?>/theme/<?php echo THEME; ?>/img/hero.jpg);"></div>
        <h1>Welcome!</h1>
        <h3></h3>
        <a href="new.php" class="btn">Upload a Image</a>
    </section>


<?php include_once $IN_LIONIMAGES['siteurl'] .'/inc/footer.inc.php'; ?>

config.php

    <?php
return [
    'siteurl' => 'http://sitename.com/',
];
?>

error_log

[01-Nov-2017 21:13:39 UTC] PHP Warning:  include_once(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /home/lionimag/public_html/demo/index.php on line 15
[01-Nov-2017 21:13:39 UTC] PHP Warning:  include_once(http://lionimages.dnt5.com/demo/inc/header.inc.php): failed to open stream: no suitable wrapper could be found in /home/lionimag/public_html/demo/index.php on line 15
[01-Nov-2017 21:13:39 UTC] PHP Warning:  include_once(): Failed opening 'http://lionimages.dnt5.com/demo/inc/header.inc.php' for inclusion (include_path='.:/opt/cpanel/ea-php70/root/usr/share/pear') in /home/lionimag/public_html/demo/index.php on line 15
[01-Nov-2017 21:13:39 UTC] PHP Warning:  include_once(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /home/lionimag/public_html/demo/index.php on line 16
[01-Nov-2017 21:13:39 UTC] PHP Warning:  include_once(http://lionimages.dnt5.com/demo/inc/nav.inc.php): failed to open stream: no suitable wrapper could be found in /home/lionimag/public_html/demo/index.php on line 16
[01-Nov-2017 21:13:39 UTC] PHP Warning:  include_once(): Failed opening 'http://lionimages.dnt5.com/demo/inc/nav.inc.php' for inclusion (include_path='.:/opt/cpanel/ea-php70/root/usr/share/pear') in /home/lionimag/public_html/demo/index.php on line 16
[01-Nov-2017 21:13:39 UTC] PHP Warning:  include_once(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /home/lionimag/public_html/demo/index.php on line 29
[01-Nov-2017 21:13:39 UTC] PHP Warning:  include_once(http://lionimages.dnt5.com/demo/inc/footer.inc.php): failed to open stream: no suitable wrapper could be found in /home/lionimag/public_html/demo/index.php on line 29
[01-Nov-2017 21:13:39 UTC] PHP Warning:  include_once(): Failed opening 'http://lionimages.dnt5.com/demo/inc/footer.inc.php' for inclusion (include_path='.:/opt/cpanel/ea-php70/root/usr/share/pear') in /home/lionimag/public_html/demo/index.php on line 29

我想你想说:

$IN_LIONIMAGES = Array('siteurl' => 'http://sitename.com/');

那么它应该会按预期工作。 如果愿意,可以将其放入config.php文件中

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM