Welcome Guest, Not a member yet? Register   Sign In
how to mix html and php?
#9

(This post was last modified: 02-03-2022, 04:10 PM by John_Betong.)

@richb201 ,

https://www.php.net/manual/en/language.types.string.php

I started using PHP HereDoc strings and it greatly simplifies mixing PHP and HTML. PHP also has NowDoc strings but I very seldom use that syntax.

Plain variables are expanded within the HereDoc syntax but arrays and expressions must be enclosed in curly braces without spaces. For example
Code:
//========================
// usage:
// fred($string_array_object);
//========================
function debug($val)
{
$val= print_r($val,true);
$sty = ‘width:88%; margin:2rem auto: background-color: snow; color:#000;’:

// NOTHING FOLLOWS ____BLOCK
echo $tmp = <<< ____BLOCK
  <div style=‘$sty’>
$val
</div>
____BLOCK;
// NOTHING AFTER ;
}// endfunc
Reply


Messages In This Thread
how to mix html and php? - by richb201 - 01-30-2022, 02:42 PM
RE: how to mix html and php? - by InsiteFX - 01-31-2022, 02:04 AM
RE: how to mix html and php? - by richb201 - 01-31-2022, 06:27 AM
RE: how to mix html and php? - by InsiteFX - 02-01-2022, 02:01 AM
RE: how to mix html and php? - by richb201 - 02-03-2022, 08:37 AM
RE: how to mix html and php? - by Acuru - 02-03-2022, 09:22 AM
RE: how to mix html and php? - by richb201 - 02-03-2022, 12:15 PM
RE: how to mix html and php? - by Acuru - 02-03-2022, 12:48 PM
RE: how to mix html and php? - by John_Betong - 02-03-2022, 04:10 PM
RE: how to mix html and php? - by InsiteFX - 02-04-2022, 01:52 AM
RE: how to mix html and php? - by Kerry Watson - 02-04-2022, 05:28 AM
RE: how to mix html and php? - by richb201 - 02-04-2022, 01:27 PM
RE: how to mix html and php? - by John_Betong - 02-04-2022, 04:08 PM
RE: how to mix html and php? - by InsiteFX - 02-05-2022, 03:08 AM
RE: how to mix html and php? - by John_Betong - 02-05-2022, 04:07 AM



Theme © iAndrew 2016 - Forum software by © MyBB