Herodocs are useful for multi-line strings and avoiding quoting issues. It prevents from escapinging of characters in php
EX1 )
$sql = <<<SQL
select *
from TABLE_NAME
where id =1
and product_name = "widgets"
SQL;
O/P:
select *
from TABLE_NAME
where id =1
and product_name = "widgets"
EX2)
$sql =<<<ENDHTML
"This is Test '"Test111"'"
<<<ENDHTML;
O/P:
"This is Test '"Test111"'"
Restriction with herodocs are :
1- Dont leave any whitespace after the ending HERODOC
2- Always use semicolon after HERODOC
0 Comment(s)