Home  >  Article  >  Backend Development  >  php 启用session 后插入文件路径错误

php 启用session 后插入文件路径错误

WBOY
WBOYOriginal
2016-06-23 13:56:371036browse

我后台登陆用session,只用后台一登陆前台index.php插入文件 就会读出后台的top.php,而不是根目录下的top.php。本地没有问题。一到服务器上就出问题了。
本地和服务器都是win2003 + php5.2.5
我没有绝对路径,全是相对路径。


回复讨论(解决方案)

require_once('top.php');
加载的是当前文件所在目录的 top.php

require_once('top.php');
加载的是当前文件所在目录的 top.php



现在就是不加载当前目录下的top.php,加载的是后台的的top.php

给出你的目录结构

把错误提示贴出来看看

把错误提示贴出来看看


没有提示错误,就是调用manage下的top.php

目录结构:
/根目录
└---top.php
└---index.php
└---manage (文件夹)
             └---login.php
              └---top.php
在index.php里插入了top.php  
用login.php登陆后,访问根目录下的index.php就会加载 manage/top.php,而不是加载根目录下top.php
很奇怪的问题

高手请进看看怎么回事呀!

登录表单的 action 不是 manage/login.php 吗?

你在index.php里面getcwd()打印当当前路径看看

你在index.php里面getcwd()打印当当前路径看看


本地返回正确目录
远程返回:c:\windows\system32\inetsrv

目录结构:
/根目录
└---top.php
└---index.php
└---manage (文件夹)
             └---login.php
              └---top.php
在index.php里插入了top.php  
用login.php登陆后,访问根目录下的index.php就会加载 manage/top.php,而不是加载根目录下top.php
很奇怪的问题



你在访问index.php 时如果用的require的话就是对的 ,因为如果是require("index.php") 那么就相当与吧当前目录(login.php)中的top也导入了 ,若果不是用的requrire那我就不知道是怎么回事了 

用dirname(__FILE__) 返回正确路径,但还是调用manage下的top.php!

 

问题还是没有解决,但还是谢谢各位,见者有份!
如果谁有好的想法记得联系我呀!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:关于ob_get_clean的疑问Next article:js中Array对象疑问