stop preventing HTML code rendering with Return and Die function in php -
as know in php script when call return or die prevents rest of html codes rendering.
in occasion when want stop php script not whole page do?
ex:
<?php if(!isset($_post['txt_username'])) { echo "please enter username"; return; } ?> <i want="this html">to rendered</i>
i want html codes rendered afterward. reading.
your question not clear, need stop php code execute, html render? might need output buffer or functions.
e.g.:
<form action="" method="post" > <input type="text" name="txt_username" /> <input type="submit" /> </form> <?php function dosmth(&$password) { if(!isset($_post['txt_username'])) { echo "please enter username"; return false; } $password .= "333"; echo "you password has been changed $password"; } $password = 128; dosmth($password); ?> <body> <p> <b> password <?= $password; ?> </b></p> </body>
examples:
- text field set:
output:
you password has been changed 128333
your password 128333
- text field not set:
output:
please enter username
your password 128
Comments
Post a Comment