Jump to content

Welcome to Pure Warfare - The #1 Community for Pures

Welcome to Pure Warfare - The #1 Community for Pures, like most online communities you must register to view or post in our community, but don't worry this is a simple free process that requires minimal information for you to signup. Be apart of Pure Warfare - The #1 Community for Pures by signing in or creating an account.
  • Start new topics and reply to others
  • Subscribe to topics and forums to get email updates
  • Get your own profile page and make new friends
  • Send personal messages to other members.

Basics of PHP


Recommended Posts

PHP stands for PHP: Hypertext Preprocessor, it's a server side scripting language which supports many databases, the main one being MySQL. PHP is widely used as it can be used on many operating systems.

 

PHP can start in various ways.

 

For example:

 

<?php?>

 

Or:

 

<script language="php"></script>

 

However, I always used the first and it's recommended.

Basic Syntax

 

In order to make PHP display something, the easiest thing is the Hello World tutorial.

 

To do this, it's quite simple.

 

You open PHP with <?php, simple enough?

 

Then you Echo something for the script to display echo "Hello World";

 

Next, closed PHP. ?>

 

Put it all together.

 

<?phpecho "Hello World";?>

 

Save it as index.php, well done you've used your first syntax.

 

 

 

 

In order to use PHP in dynamic web pages, you'll need to know a few basic things.

 

You will need to include HTML for the correct formatting.

 

To include HTML, there are two main ways.

 

For example:

<?phpecho "<b>Hello World</d>";?>

 

That will simple make the Hello World bold.

 

This next way is my favourite way, it's easier and you can include more:

<?php		 echo <<<HTML<b>Hello World</b>HTML;?>

 

 

 

 

 

The next thing you need to know is how to include files. It's easier to include the HTML in to the files, from a main file.

 

For example, index.php could have an include from main.php, main.php will have the HTML inside of it, so that if a link changes, you only need to change the main.php rather than each file separately.

 

To include a file you can either use this:

include 'main.php';

 

Or:

 

require 'main.php';

 

Both codes do the exact same thing, however, with an include the script will continue to run if the file is not found. With a require, the script will generate a fatal error and will fail to continue.

 

To be continued.


favadmin.png
IRC Nick - ``Karl
"You lost me at biased."
Need help? PM me

purewarfare.png
Link to comment
Share on other sites

  • 1 year later...
  • 1 year later...
  • 1 month later...
Guest
This topic is now closed to further replies.
×
  • Create New...