User Tools

Site Tools


en:web_development:layout:php

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:layout:php [2022/03/21 12:14]
mag [PHP]
en:web_development:layout:php [2023/08/16 09:33] (current)
Line 235: Line 235:
   * If you want the ability to personalise your site for your customers, (think Amazon recommending particular items based on what you've bought previously or Facebook showing posts from your friends) then you'll need code that runs on a server to access a database and provide that data.   * If you want the ability to personalise your site for your customers, (think Amazon recommending particular items based on what you've bought previously or Facebook showing posts from your friends) then you'll need code that runs on a server to access a database and provide that data.
   * Commonly used server side scripts are Node.js, Net.data, Python and PHP. We'll be using PHP, but you're welcome to try others to see if they're better for your needs.   * Commonly used server side scripts are Node.js, Net.data, Python and PHP. We'll be using PHP, but you're welcome to try others to see if they're better for your needs.
-  * PHP code has many similarity to Javascript, so you won't have to learn everything twice. +  * PHP code has many similarities to Javascript, so you won't have to learn everything twice. 
-  * To be processed by the server, all PHP code needs to be in a file with the '.php' extension, which can include both HTML and PHP code.+  * To be processed by the server, all PHP code needs to be in a file with '.php' extension, which can include both HTML and PHP code.
   * Your server needs a way to differentiate PHP from the rest of your code so it doesn't just send it all to the client. For this, we enclose all PHP code in the following symbols.   * Your server needs a way to differentiate PHP from the rest of your code so it doesn't just send it all to the client. For this, we enclose all PHP code in the following symbols.
 <code><?php <code><?php
Line 244: Line 244:
 ==== Include ==== ==== Include ====
   * Before we get into the depths of PHP, let's start with something simple, but very powerful in its time-saving capabilities.   * Before we get into the depths of PHP, let's start with something simple, but very powerful in its time-saving capabilities.
-  * Imagine that you have twenty pages (or more) to manage rather than just the three we have in this folder so far. Now imagine that your boss / client has just asked you to change the company phone number, which appears at the bottom of every page. You'd have to make the change twenty times, then check every single page to make sure you'd done it properly. That's how mistakes made.+  * Imagine that you have twenty pages (or more) to manage rather than just the three we have in this folder so far. Now imagine that your boss / client has just asked you to change the company phone number, which appears at the bottom of every page. You'd have to make the change twenty times, then check every single page to make sure you'd done it properly. That's how mistakes are made.
   * Instead, wouldn't it be better to have one place to change that data and every page would refer to that place? PHP allows us to separate our pages into parts and reuse those wherever we want to.   * Instead, wouldn't it be better to have one place to change that data and every page would refer to that place? PHP allows us to separate our pages into parts and reuse those wherever we want to.
   * Create a new file called 'layout.php'. This will replace our 'layout.html' file.   * Create a new file called 'layout.php'. This will replace our 'layout.html' file.
Line 409: Line 409:
     include("footer.php");     include("footer.php");
 ?></code> ?></code>
-  * Again, notice that we've added <html><main</html> tags to correctly position the content.+  * Again, notice that we've added <html><main></html> tags to correctly position the content.
   * Upload both these files to the server and check that they look correct.   * Upload both these files to the server and check that they look correct.
   * Also notice the 'title' in the tab, which currently says 'Document'.   * Also notice the 'title' in the tab, which currently says 'Document'.
en/web_development/layout/php.1647890044.txt.gz · Last modified: 2023/08/16 09:33 (external edit)