2016-07-22 56 views
-2

我们能否使用,如果在形式上行动else条件是这样的:如果表单操作else条件

<form action="<?php if(condition) 
{ 
//redirect to some view file or show error 
//run some queries 

} 
else 
{ 
//redirect to another view 
} 
?>" method="post"> 
+2

是的!你应该刚刚尝试过,现在接受的答案是“是”/“否”? –

+5

而不是写这个问题 - 你可以测试。 –

+0

提供条件内的代码回声一个字符串是一个有效的表单操作,那么是的。我怀疑有更多这个问题 – Steve

回答

2

试试这个

<?php if(condition) 
    { 
//your html code goes here 
    echo <<<HTML 
<!--some codes--> 
    HTML; 
    } else { 
    //your another html code goes here 
    echo <<<HTML 
<!-- some another codes codes--> 
    HTML; 
    }