Link to home
Start Free TrialLog in
Avatar of Bruce Gust
Bruce GustFlag for United States of America

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;

Open in new window


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?
Avatar of Kimputer
Kimputer

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.
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
A note on { } in HEREDOC

Example
$code = "123456";
echo <<< HTML
   Product  sku$codeabc
HTML;

Open in new window

Result:  Undefined variable: codeabc

$code = "123456";
echo <<< HTML
   Product  sku$codeabc
HTML;

Open in new window

Or
$product=array(
	"id" => 21,
	"product" => "Blue pen"
);

echo <<< HTML
   Product :$product['product']
HTML;

Open in new window

Result: Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)
As opposed to
$product=array(
	"id" => 21,
	"product" => "Blue pen"
);

echo <<< HTML
   Product :{$product['product']}
HTML;

Open in new window


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.
Avatar of Bruce Gust

ASKER

Excellent!

Thanks!
You are welcome.