【发布时间】:2014-05-01 03:26:55
【问题描述】:
如何退出当前的 php 脚本?
例如:
page.php
<?php
include('./other-page.php');
?>
<h4>this text always shows</h4>
其他页面.php
<?php
if($_GET['v'] == 'yes'){
//this is the code I want
}
?>
<h1>you did not say yes <!-- There is an entire html page here in the real program-->
</h1>
我想让以下输出发生
index.php?v=yes:
<h4>this text always shows</h4>
index.php?v=whatever
<h1>you did not say yes <!-- There is an entire html page here in the real program-->
<h4>this text always shows</h4>
基本上,我想要一个退出当前文件的函数(跳到末尾),但继续处理包含它的文件。
【问题讨论】:
-
阅读 php 文档。您可以使用返回
-
是的,这是个骗子。而且我阅读了文档,我只是不太擅长在其中找到东西。
-
好的,无论如何您也可以使用 return 从 include 中返回值。喜欢。
$foo = include('bar.php'); // has what bar.php returns (return)