Last Updated : Jul 1, 2023
Here we defined html block with script within this we defined variable ‘str’ with ‘var’ keyword.
It holds string ‘Hi Everyone’ then we know for printing in script we need to use ‘document.writeln()’ method with the help of document service.
- A php script can be placed anywhere in the document. A php script starts with <?php and end with ?>.
- The default file extension for php files is “.php” and php statements end with ‘;’ semicolon.
- In html body block we defined script tag and within that we created variable ‘str’ using ‘var’ keyword then we stored string ‘Hi Everyone’ on variable ‘str’.
- For embed script code we need to define ‘document.writeln()’ line between script tag within double quotes. In this method we need to pass variable ‘str’ so we can easily display them on webpage successfully.
- In php code we need to use echo() method for printing them on webpage. Here we passed string value you can try to explore some other types of values also we gets successful result on webpage.
First we need to start our xampp server then we load this program on browser we can see result of passed variable str message of ‘Hi Everyone’ on webpage.