Hướng dẫn dùng semicolon php trong PHP

i have code like this :

';
?>

how can it return html like this :

 

Big Thanks

asked Apr 23, 2016 at 13:37

Japar SJapar S

571 silver badge7 bronze badges

3

Not entirely sure what information you need but here's an overview...

You can use both single and double quotes when echoing in php,

echo "Some text to echo"; // Some text to echo

or

echo 'Some text to echo'; // Some text to echo

If you want to echo the quote type used to encapsulate the string, escape it like,

 echo "Some text with an \"escaped\" quote"; // Some text with an "escaped" quote

Strings within double quotes will accept a variable inline,

$var = "variable";
echo "A string with a $var in it"; // A string with a variable in it

Whereas strings within single quotes need to be concatinated with variables,

$var = 'variable';
echo 'A string with a '.$var.' in it'; // A string with a variable in it

Check out http://php.net/manual/en/function.echo.php for full details and examples.

answered Apr 23, 2016 at 13:56

SteveSteve

1,64313 silver badges27 bronze badges

Since you quoted the string with single quotes, you have to escape them inside the string.

Simply add a backslash \ before each single quote inside the string:


Also you can do that in a few other ways like:

echo "

Double quotes lets you simply embed a variable instead of concating, but now you have to escape double quotes.

answered Apr 23, 2016 at 13:48

Jakub MatczakJakub Matczak

15k5 gold badges48 silver badges61 bronze badges

0

I'd suggest you to write this variable within an opening and closing php tag.



Click me

This generates:

Click me

answered Apr 23, 2016 at 13:48

Hướng dẫn dùng semicolon php trong PHP

Not the answer you're looking for? Browse other questions tagged php or ask your own question.