User Tools

Site Tools


en:web_development:media:javascript

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:web_development:media:javascript [2021/12/21 17:46]
mag [PHP Variables]
en:web_development:media:javascript [2023/08/16 09:33] (current)
Line 150: Line 150:
   * Variables in PHP are always represented by <html>$</html>and the variable name.   * Variables in PHP are always represented by <html>$</html>and the variable name.
   * In this case, we have a variable named 'page' and we assign it the value of 'media' which is the page name.   * In this case, we have a variable named 'page' and we assign it the value of 'media' which is the page name.
 +  * Add a command to display the variable.
 +
 +<code><?php
 +    $page = "media";
 +    echo $page;
 +    include("header.php");
 +    include("menu.php");
 +?></code>
 +
 +  * When you save, upload and run the code, you'll see the word 'media' at the top.
 +  * The code in 'header.php' is part of the same page, so we can use our variable there too.
   * Now open 'header.php' and replace the <html><script></html> line with the following.   * Now open 'header.php' and replace the <html><script></html> line with the following.
 <code>    <script src="<?php echo $page; ?>.js"></script></code> <code>    <script src="<?php echo $page; ?>.js"></script></code>
en/web_development/media/javascript.1640137610.txt.gz · Last modified: 2023/08/16 09:33 (external edit)