If 语句中的 If 语句
我正在检查搜索表单上的复选框是否已选中。如果选中该框,则其输出值将为“否”。
因此,如果值为“No”,那么我想使用 If 语句来回显某些 PHP。问题是,我想要回显的 PHP 本身就是一个实际的 If 语句。
这是我现在的代码:
$showoutofstock = $_SESSION['showoutofstock'];
if ( $showoutofstock == "No" ) {
}
if($_product->isSaleable()): {
}
I'm checking to see if a check box has been checked on a search form. If that box has been checked, the value it outputs will be "No".
So if the value is "No", then I want to use an If statement to echo some PHP. The problem is, the PHP that I want to echo is an actual If statement itself.
Here's my code right now:
$showoutofstock = $_SESSION['showoutofstock'];
if ( $showoutofstock == "No" ) {
}
if($_product->isSaleable()): {
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你不能真正“回显一些 PHP”。 PHP在服务器端进行处理,结果通常是浏览器客户端读取并显示的HTML。
目前尚不清楚您实际上想要实现什么目标。你能澄清一下吗?
这可能会有所帮助——它只是展示如何嵌套 if 语句,这可能就是您所要求的:
You can't really "echo some PHP". PHP is processed on the server-side, and the result is usually HTML that the browser client reads and displays.
It's not clear what you're actually trying to accomplish. Can you clarify a bit?
This might help though -- it's simply showing how to nest if statements, which may be all that you're asking for:
在编写另一个 if 之前,您要关闭 if ,请
像这样尝试,是的,您可以检查复选框的值,并可以在该 if 子句中进行相应的编码
you are closing your if before writing another if inside it
try it like this and yes you can check for the value of check box and can code accordingly inside that if clause