Home >Backend Development >PHP Tutorial >php中define防止跳墙

php中define防止跳墙

WBOY
WBOYOriginal
2016-06-06 20:30:171346browse

这个是入口shiyan.php

{

<code>define('ACC','true');
require('itshi.php');
include('shiyan.html');
</code>

}

itshi.php
{

<code>defined('ACC') || exit('ACC 未定义');
$take = 1888;
</code>

}

shiyan.html
{

<code><a href="two.php" target="_blank">点击我</a>
<div>
    <?php echo $take; ?>
</div>
<a href="shiyan.php" target="_blank">返回实验</a>
</code>

}

{
two.php

<code>require('itshi.php');
</code>

}
当我运行shiyan.php的时候,点击a标签进入two.php怎么提示ACC未定义啊,不是一开始就在shiyan.php就定义了ACC吗?

回复内容:

这个是入口shiyan.php

{

<code>define('ACC','true');
require('itshi.php');
include('shiyan.html');
</code>

}

itshi.php
{

<code>defined('ACC') || exit('ACC 未定义');
$take = 1888;
</code>

}

shiyan.html
{

<code><a href="two.php" target="_blank">点击我</a>
<div>
    <?php echo $take; ?>
</div>
<a href="shiyan.php" target="_blank">返回实验</a>
</code>

}

{
two.php

<code>require('itshi.php');
</code>

}
当我运行shiyan.php的时候,点击a标签进入two.php怎么提示ACC未定义啊,不是一开始就在shiyan.php就定义了ACC吗?

你的 two.php 时只包含了 itshi.php,而 itshi.php 里没定义 ACC 常量,也没有包含 shiyan.php 文件啊,当然提示 AAC 未定义了,你可以在 itshi.php 最上面 require 'shiyan.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