W3docs

if block inside echo statement?

It is not possible to include an "if" block inside an "echo" statement in PHP.

It is not possible to include an "if" block inside an "echo" statement in PHP. "echo" is a language construct used to output a string, whereas an "if" statement is used for control flow. If you want to output a string based on the outcome of an "if" statement, you would need to use the "echo" statement within the code block of the "if" statement.

For example:

Example of an if block inside echo statement in PHP

php— editable, runs on the server