开发者

How can you exclude files in php?

im using php to include background colors, so that users can change them, but i also need to know how to exclude them, or i need to know if it will auto开发者_JAVA百科matically change once they hit the new page to include them i do this:

<?php include('background.php') 
?>


PHP is scripting language, that means its interpreted not compiled, so for each request it will be interpreted again.

If you included something in your previous request using some condition, and your condition is false in next request those files will not be included.

I hope this helps you.


First thing, you can include the file in PHP. But there is a way which can help you to solve your problem.

You can use same variable names in both files. e.g. Once you include first file i.e.

include("file1.php");

which has

<?php
$color1 = "red";
?>

Then if you may include second file may be

include("file2.php");

which has

<?php
$color1 = "blue";
?>

This will replace the first variable value red with blue color.

So anyways this way your new background colors will be seen.


Uhm, the included files are usually included on a per-request base. So if you include 1.php in the first request and include 2.php in the second request, the second request does not know that the previous request did include 1.php.

If you mean to un-include a file during a single request, no I do not think that would be possible.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜