- Joined
- Dec 26, 2008
- Messages
- 781
- Reaction score
- 225
This is an extremely simple tutorial, I'll make one later about how to incorporate databases into this, for now it'll be file-based.
What does this do?
Step 1.
Step 2.
About the code
This is an extremely useful piece of code which can be used to make simple CMS's or websites. Hope this helps anyone, I tried making the tutorial as simple as I could to understand
What does this do?
This tutorial will teach you how you can make a configuration file for users to fill information out in. The filled out information can be used easily across the site
Step 1.
Make two files: config.php and index.php
inside of index.php put the following code:
inside of index.php put the following code:
Code:
<?php
include('config.php');
?>
<title><?php echo $title; ?> - Index</title>
Welcome to <?php echo $title; ?>! This website was made by <?php echo $name; ?>.
Step 2.
inside of config.php put the following code:
You can change the variables in config.php to change what is displayed on the site
Code:
<?php
$title = "Website"; /* The name of your website */
$name = "Name"; /* Your name */
?>
About the code
First part of the code, the <?php and ?> tags
The PHP tags will make the inside code PHP code
----------------------------------------------------------------------------------------------------------------------------------------------------
include('');
This PHP script will include config.php, letting the webpage with the include code use variables, connections etc from config.php
----------------------------------------------------------------------------------------------------------------------------------------------------
Echos and Variables
This PHP script will find $variable in the current file or any included files and echo it. Echoing means to display, which you can see using the code.
----------------------------------------------------------------------------------------------------------------------------------------------------
Variables in config.php
The above code defines each variable. In this case the code echo $title; would display Website
Code:
<?php
PHP CODE
?>
----------------------------------------------------------------------------------------------------------------------------------------------------
include('');
Code:
include('config.php');
----------------------------------------------------------------------------------------------------------------------------------------------------
Echos and Variables
Code:
<?php echo $variable; ?>
----------------------------------------------------------------------------------------------------------------------------------------------------
Variables in config.php
Code:
<?php
$title = "Website";
$name = "Name";
?>
This is an extremely useful piece of code which can be used to make simple CMS's or websites. Hope this helps anyone, I tried making the tutorial as simple as I could to understand