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:
<?php
if (!isset($_POST['myform'])) {
?>
<form method="POST" action="<?php if (isset($myform_worked)) { echo 'somepath'; } ?>" accept-charset="UTF-8">
<?php } //if-closing bracket ?>
Solution 2:
You forgot to close PHP tag before entering HTML mode.
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 ?>
.
<?php
if (!isset($_POST['myform'])) {
echo '<form method="POST" action="'.isset($myform_worked)?'somepath':''.'" accept-charset="UTF-8">';
}
?>
HTML+PHP
<?php if (!isset($_POST['myform'])) { ?>
<form method="POST" action="<?php if (isset($myform_worked)) { echo 'somepath'; } ?>" accept-charset="UTF-8">
<?php } ?>
Solution 4:
<?php echo "hello world";?>
OR Shorthand
<?="hello world"?>
Post a Comment for "How To Write Php Within Html Within Php?"