jrahma
August 15, 2017, 3:59pm
1
Hi,
I am trying to add a google font in my html text in PHP but it’s not working.
type or paste code here$body .= "<meta charset='utf-8'>";
$body .= "<link href='https://fonts.googleapis.com/css?family=Harmattan' rel='stylesheet'>";
$body .= "</head>";
$body .= "<p style='direction: rtl; font-size: large; font-family: \'Harmattan\', sans-serif;'>هذه الرسالة تم إرسالها تلقائيا لذا يرجى عدم الرد</p><hr><br><br>";
$body .= "<p style='d$body .= "<meta charset='utf-8'>";
$body .= "<link href='https://fonts.googleapis.com/css?family=Harmattan' rel='stylesheet'>";
$body .= "</head>";
$body .= "<p style='direction: rtl; font-size: large; font-family: \'Harmattan\', sans-serif;'>هذه الرسالة تم إرسالها تلقائيا لذا يرجى عدم الرد</p><hr><br><br>";
$body .= "<p style='direction: rtl; font-size: large; font-family: \'Harmattan\', sans-serif;'>السلام عليكم ورحمة الله</p><br><br>";
irection: rtl; font-size: large; font-family: \'Harmattan\', sans-serif;'>السلام عليكم ورحمة الله</p><br><br>";
Where is my mistake?
Thanks,
Jassim
The first this to try would be to remove
type or paste code here
SamA74
August 15, 2017, 4:10pm
3
By the look of it, that script will not output valid html (if anything at all).
I’m not surprised it doesn’t work.
Run the output through the validator .
jrahma
August 15, 2017, 10:50pm
4
ok I have corrected all validation problem but I only have the following not fixed…
How can i fix it?
Error Line 1, Column 358: “Harmattan” is not a member of a group specified for any attribute
Error Line 1, Column 372: “sans-serif” is not a member of a group specified for any attribute
Error Line 1, Column 513: “Harmattan” is not a member of a group specified for any attribute
Error Line 1, Column 527: “sans-serif” is not a member of a group specified for any attribute
The link is here:
https://www.softnames.com/temp/test-nasser.php
Thanks
SamA74
August 15, 2017, 11:14pm
5
You are escaping the single quotes when the string is defined in double quotes, so you should not escape them.
Also because the font name is one word, you don’t need quotes on it anyway.
jrahma
August 15, 2017, 11:27pm
6
Yes, Great… I removed the single quotes and it’s working but can you please explain the first part? what if the name is two words? How will I define it?
Thanks.
I prefer using php’s heredoc:
$body = <<< ____TMP
<meta charset='utf-8'>
<link href='https://fonts.googleapis.com/css?family=Harmattan' rel='stylesheet'>
</head>
<meta charset='utf-8'>
<link href='https://fonts.googleapis.com/css?family=Harmattan' rel='stylesheet'>
</head>
<body>
<p style='direction: rtl; font-size: large; font-family: Harmattan, sans-serif;'>
السلام عليكم ورحمة الل
</p>
<br><br>
____TMP;
echo $body;
Please note that only linefeeds are allowed after the trailing ____TMP;
Check the online php manual for usage examples.
3 Likes
system
Closed
November 15, 2017, 7:03am
8
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.