>백엔드 개발 >PHP 튜토리얼 >php 两次include后,第一个include里的变量无效了解决方法

php 两次include后,第一个include里的变量无效了解决方法

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB원래의
2016-06-13 11:37:031425검색

php 两次include后,第一个include里的变量无效了
目录结构
+ root
  index.php     
  config.php    
  +c
     index.php

root/config.php 里的内容
$shell['jquery'] = "jquery 1.4";
?>

root/index.php 里的内容
include "config.php";
print $shell['jquery'];
?>

root/c/index.php 里的内容
include "../index.php";
?>

访问root/index.php返回
jquery 1.4

访问root/c/index.php返回
Notice: Undefined variable: shell in H:\software\dev\php\xampp\htdocs\phptest\index.php on line 3


请问,两次include 后变量为什么会失效呢?正确的做法应该是怎样做?
谢谢大家了
      

php
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.