How To Write Php Within Html Within Php?
I have recently asked this question, but rather than getting a direct answer, I was shown how to use the ternary operator to simplify my code by substituting if statements inside m
Solution 1:
You did not close the open php-block beforehand. The working Syntax would be like this:
<?php//php code?><!--HTML-Code--><?php?>
Or according to your problem:
<?phpif (!isset($_POST['myform'])) {
?><formmethod="POST"action="<?phpif (isset($myform_worked)) { echo'somepath'; } ?>"accept-charset="UTF-8"><?php } //if-closing bracket ?>
Solution 2:
Solution 3:
Can you try this, inside php. In php page, adding php code inside the html tags looks like <?php //your php code here ?>
.
<?phpif (!isset($_POST['myform'])) {
echo'<form method="POST" action="'.isset($myform_worked)?'somepath':''.'" accept-charset="UTF-8">';
}
?>
HTML+PHP
<?phpif (!isset($_POST['myform'])) { ?><formmethod="POST"action="<?phpif (isset($myform_worked)) { echo'somepath'; } ?>"accept-charset="UTF-8"><?php } ?>
Solution 4:
<?phpecho"hello world";?>
OR Shorthand
<?="hello world"?>
Post a Comment for "How To Write Php Within Html Within Php?"