duan0821 2013-08-12 09:05
浏览 67
已采纳

在PHP中不起作用的变量和会话变量包括

OK.. forgive me, there are a couple similar questions posted already with the correct responses... I knew someday I would have to ask the people of the internet for help but I never thought it would be something so stupid...

here is my code.. so far..

index.php:

include "http://www.mywebsite.com/shared.php";
$page = "homepage";

include "http://www.mywebsite.com/htmlheader.php"; //trying to use "page" variable in here
echo ("<br>test2: " . $_SESSION['test']);
include "http://www.mywebsite.com/htmlfooter.php";

shared.php:

session_start();
$_SESSION['test'] = "what the f_ck im scared";

htmlheader.php:

echo ("test1: " . $page . "<br>" . $_SESSION['test']);

Output right now is:

test1:

test2:

(so the pages are being included.. just not able to use the variables..) From what I understand in its current state this should be printing something like:

test1: what the f_ck im scared

test2: homepagewhat the f_ck im scared

..The funny thing is I was not having any issue with the include using the variable. I had added some things but then it randomly stopped working so I reduced it down to this to try and figure out what the problem was.. I am assuming I have made some silly mistake.

  • 写回答

2条回答 默认 最新

  • douri4459 2013-08-12 09:22
    关注

    Ensure that you have started the session with session_start();

    also check whether allow_url_fopen or allow_url_include or both have been set to 0 (disabled) in php.ini. if yes try to activate it

    include "htmlheader.php";
    

    instead of

    include "http://www.mywebsite.com/htmlheader.php";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?