父变量无法识别的问题

时间:2019-06-27 16:06:44

标签: php

我遇到了有关变量的奇怪变量错误。因此,我得到了一个 config.php 文件,其中包含我的数据库连接(PDO)和一个变量:$wURL = "http://{$_SERVER['HTTP_HOST']}/"; 我的问题是在我的 index.php 中,我包含了带有该变量的文件。 (例如:

<?php
require 'steamauth/steamauth.php';
require 'config.php';
include ("assets/config/config.php");
include ("assets/config/fetch.php");
?>
<!DOCTYPE html>
<html lang="fr">
<head>
  <title>HyperionRP I Accueil</title>
  <link rel="icon" type="image/png" href="<?= $wURL ?>assets/img/logo.png">
  <?php include('assets/templates/css.php'); ?>
</head>
<!-- Rest of my code -->

并且在我的css.php(或任何其他)文件中无法识别该变量 (我的css.php的内容:

<!-- CSS  -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0"/>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<link href="<?= $wURL ?>assets/css/style.css" type="text/css" rel="stylesheet" media="screen,projection"/>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
<!-- <link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.1.0/css/all.css" crossorigin="anonymous"> -->
<meta name="description" content="Hyperion RP. Serveur FiveM Serious Roleplay. Developped by tholeb.">
<meta name="author" content="tholeb" />
<meta name="theme-color" content="#651fff">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<meta name="keywords" content="roleplay, hyperion, hollywood, fr, french, francais, fivem, gtarp, gta rp, rp, gta, gtav, gta v, gta5, gta 5, hyperion roleplay, v2, topserveur">
<?php include("".$wURL."assets/templates/loader.php") ?>
<link rel="stylesheet" href="http://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.7/css/select2.min.css" rel="stylesheet" />

所以它会导致php错误...

  

注意:未定义的变量:第14行的D:\ xampp \ htdocs \ assets \ templates \ css.php中的wURL

     

警告:include(assets / templates / loader.php):无法打开流:第14行的D:\ xampp \ htdocs \ assets \ templates \ css.php中没有此类文件或目录

     

警告:include():无法在D:\ xampp \ htdocs \ assets \ templates \ css中打开'assets / templates / loader.php'进行包含>(include_path ='D:\ xampp \ php \ PEAR') .php>第14行

有什么办法可以解决该问题?那在我的网站中非常重要,因为我不想在10个不同的页面上使用10次相同的文件。

感谢您的回答

0 个答案:

没有答案