How to echo variable on the screen with $var
To echo a variable on PHP, you can use the echo or print functions, which can display the value of a variable as text.
For example, if you have a variable named $name that contains the string "John",
you can use: echo $name;
// This will output John print $name;
// This will also output John
You can also use double quotes (") to include the value of a variable within a string.
For example, you can use: echo "Hello, $name";
// This will output Hello, John However, if you use single quotes ('),
the variable name will not be replaced by its value.
For example, you can use:
echo 'Hello, $name'; // This will output Hello, $name
PHP Echo |
Explore My Other Channel for More Cool and Valuable Insights
π Youtube Learn Tech Tipsπ Tiktok
π Facebook:Demo 1 - echo on string
<?php
$commonlink = $link . "css/commons.css";
$searchImg = $link . "image/search-red.png";
echo '
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Download Free Games - Stop Paying for Games</title>
<link rel="icon" type="image/x-icon" href="image/favicon.ico"/>
<link rel="shortcut icon" type="image/x-icon" href="image/favicon.ico"/>
echo "<link href='$fontlink'; rel='stylesheet' type='text/css'>";
echo "<link href='$commonlink'; rel='stylesheet' type='text/css'>";
echo "</head>";
?>
Demo 2 - echo on variable
<?php
$link = $link . "css/commons.css";
echo $link . " Hello Learn Tech Tips";
?>
Thank you for reading this post. I hope you found it helpful and easy to follow. If you have any feedback or questions about
How to echo variable on PHP ,
please share them in the comments below. I would love to hear from you and discuss this topic further
✋✋✋✋
Webzone Tech Tips Zidane, all things tech tips web development
- I am Zidane, See you next time soon ✋✋✋✋