Bruce Gust
asked on
What is "<<<OUT"?
$out = <<<OUT
<form method="post">
<input type="hidden" name="usrID" id="usrID" value="{{usrID}}"> <input type="hidden" name="usrFN"
id="usrFN" value="{{usrFN}}"> <input
type="hidden" name="usrLN" id="usrLN" value="{{usrLN}}"> <input type="hidden"
name="usrVerified" id="usrVerified" value="{{usrVerified}}">
<h4 style="margin:5px 0;">Is this You?</h4>
{{usrFN}} {{usrLN}} <br> {{usrCity}} {{usrState}}, {{usrZip}} <br>
<div class="btnConfirmWrap" style="margin-top:5px;">
<input class="btnConfirmYes" type="button" name="verifyUseryes" id="verifyUseryes" value="Yes" style="width: 60px">
<input class="btnConfirmNo" type="button" name="verifyUser" id="verifyUserno" value="No" style="width: 60px">
</div>
</form>
OUT;
What is "<<<OUT"?
I've tried googling this thing and I don't know if I'm searching for the wrong thing, but I keep coming up empty.
What is it?
Heredoc syntax is an excellent pairing with query results via the object-oriented fetch_obj() methods. It lets you substitute PHP variables into templates without any need for fiddly punctuation. Instead of writing lots of quotes and brackets, or worse, switching in and out of PHP, you just create the template with the PHP variable names in it, and "voila."
In the instant case it looks like you're using a Laravel template or something like that, but it's still useful, and avoids a host of syntax issues with quote marks.
In the instant case it looks like you're using a Laravel template or something like that, but it's still useful, and avoids a host of syntax issues with quote marks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
A note on { } in HEREDOC
Example
), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)
As opposed to
The { } tells PHP exactly what part of the string is a variable which allows you to embed your variables in any configuration into the resulting string.
Example
$code = "123456";
echo <<< HTML
Product sku$codeabc
HTML;
Result: Undefined variable: codeabc $code = "123456";
echo <<< HTML
Product sku$codeabc
HTML;
Or$product=array(
"id" => 21,
"product" => "Blue pen"
);
echo <<< HTML
Product :$product['product']
HTML;
Result: Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACEAs opposed to
$product=array(
"id" => 21,
"product" => "Blue pen"
);
echo <<< HTML
Product :{$product['product']}
HTML;
The { } tells PHP exactly what part of the string is a variable which allows you to embed your variables in any configuration into the resulting string.
ASKER
Excellent!
Thanks!
Thanks!
You are welcome.
http://php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc