What are the ways to write PHP in HTML


Update: I have problems with my code with ternary operator syntax, I get my page blank, what I want is it to show something like this:

? 18299012

<?= $hotel['cache'] ? "?" rand() : ""?>


There are several things you need to correct in your ternary operator expression:

1) The comparison must be enclosed in parentheses

2) It remains to indicate what you are comparing the array with

3) The php call is recommended to use <?php ?>

4) To concatenate the character with the random you must use a period.

5) You need to use an echo for the output

I put this code example for you to review:

<?php echo  ($hotel['cache']=='x')? '?' . rand() : ""; ?>
Scroll to Top