Jump to content
Thrill

Basic PHP Guide

Recommended Posts

Just doing a very basic PHP tutorial. PHP is a 'scripting' language, that's used on the internet. Our forum is written in PHP which connects to a MySQL backend. PHP allows us to create dynamic websites, rather than your basic HTML webpage.

 

What you'll need:

 

# Webserver of some kind, that has PHP installed.

# Notepad/Dreamweaver/'Website Maker'

# The ability to follow instructions.

 

Let's get started, first of all open up your piece of software. For me it's Dreamweaver, open up a basic HTML document which looks like this:

28j893c.png

 

Our next step is to add the PHP code tags just before the </body> tag. So it would look like this:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
?>
</body>
</html>
 

 

As you can see the PHP tags are:

 

[b]<?php
?>[/b]
 

.

 

Now we're going to add a little bit of text, to do this we use the echo function and place that in between our PHP tags. so it would look like this

 

The echo function is used by simply writing this within the PHP tags;

 

echo "https://forums.prodjex.com/ is the best!";
 

 

This will look like this:

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
echo "<b>Geeksoup.net is the best!</b>";
?>
</body>
</html>
 

 

 

 

 

Notice the " and the ;, they are very important. PHP works very well with the basic HTML, so HTML is welcome within the PHP tags. So let's put that to the test. Within your echo line of code, surround your text with the bold html tags, so it would look like this:

 

echo "<b>https://forums.prodjex.com/ is the best!</b>";
 

 

That would bold your text, just like it does in HTML. Click <a href="http://www.w3schools.com">here</a> to visit W3 schools, where you can find a list of HTML tags, which will help you customise your writing and layout and other cool things :)

 

Now we've done a bit of PHP, save the file as Something.php and upload it your webserver. The end result should look like <a href="http://www.geeksoup.net/phpguide.php">this.</a>

 

This is obviously, just a very very basic guide of PHP. You can build websites in PHP, which takes a much more amount of knowledge than adding just a little bit of text.

 

A few tips:

 

# Make sure your webserver supports PHP, if not it won't work.

# Make sure to open and close tags correctly, if not it will give out an error when you go to access the page.

# Make sure to follow the instructions carefully.

# Enjoy! :)

Share this post


Link to post
Share on other sites

Wow man, I am surprised that you got no replies. Personally, I am starting to learn PHP cause I need it for web site designing, at this is a great way to start and get a hang of it. Nice work man, keep it up :))

Share this post


Link to post
Share on other sites

Great read! You definitely know your way around the software! The part about it working with HTML - I actually never know about that before, and its very valuable to the site I'm creating, and this certainly has fixed some things up for the forums section of the site, at the moment I have tons of bugs, but I think you've cleared some of them out!

 

Great read, great tutorial, and keep up the good work!

Share this post


Link to post
Share on other sites

Everyone always rights the first page of a tutorial but they never finish it off. It makes me sad :(

What else are you looking to do? I've started to learn PHP and the best way is by trying to fix a problem.

 

Let me know and I may work on it.

Share this post


Link to post
Share on other sites

What else are you looking to do? I've started to learn PHP and the best way is by trying to fix a problem.

 

Let me know and I may work on it.

 

I've been doing small parts every now and again with PHP although normally I don't finish anything.

I was more making a statement about Guides. :( Hardly anyone finishes guides after the start.

Share this post


Link to post
Share on other sites

Very nice tutorial, and PHP is towards the top of my "to-learn" list. However, do you really recommend Dreamweaver for basic users like the general audience you'll attract to this thread? Seems almost like showing the fine features of Photoshop to someone who's never used MS Paint before lol, or maybe that's just me.

Share this post


Link to post
Share on other sites

Very nice tutorial, and PHP is towards the top of my "to-learn" list. However, do you really recommend Dreamweaver for basic users like the general audience you'll attract to this thread? Seems almost like showing the fine features of Photoshop to someone who's never used MS Paint before lol, or maybe that's just me.

Please have mixed opinions with regards to Notepad/Notepad++ VS Dreamweaver as some people are of the opinion that Dreamweaver is just for designing however I personally use Dreamweaver as it allows me to see the code, work with it and see how it looks like.

 

You really just need to be sure you set up your websites properly.

Share this post


Link to post
Share on other sites

Great guide, and thanks for writing it all out for us. One thing that I would like to add, is that it is not always necessary to use the closing php tag, the ?>. It's is not actually required, even though many think that it is.

 

I had always thought, yeah, but it's still good form to include it, but I have heard that there are advantages to not using it, and it can save some headaches later.

Share this post


Link to post
Share on other sites

That's a realy good idea Vic. There should be a tutorial section for programming tutorials based on language...it'd be a great resource for people to learn how to program in that respectable language. :) Think we can get something like this going on here, Nate? :)

Share this post


Link to post
Share on other sites
That's a good tutorial. Now if only we have a section dedicated to tutorials. That would be a useful resource to have on this forum, wouldn't it? How about it, Nathan?

Yeah it would if there were more of them out there.  Hate to create a new board for it to sit mostly empty.

Share this post


Link to post
Share on other sites
Yeah it would if there were more of them out there. Hate to create a new board for it to sit mostly empty.
You can motivate the members to write howto articles by letting them earn DD$ from writing them. How about that? The virtual currency thing is still in the works, right?

 

Or you can do it this way.

 

Don't start the section yet. Tell the members how many DD$ they can earn for each howto article they write. Then let the howto articles be posted in the existing sections. Then when you feel that there are enough howto articles to warrant a separate section, start one. You can even sweeten the deal by offering XXX bonus DD$ if there are XXX number of howto articles posted within XXX days.

 

I think 100 howto articles would be a great target. There are so many members here who are knowledgeable about stuff like that. Provided you give them the right motivation to write howto articles for this forum.

Edited by Victor Leigh

Share this post


Link to post
Share on other sites
Please have mixed opinions with regards to Notepad/Notepad++ VS Dreamweaver as some people are of the opinion that Dreamweaver is just for designing however I personally use Dreamweaver as it allows me to see the code, work with it and see how it looks like.

 

You really just need to be sure you set up your websites properly.

I would recommend the netbeans for PHP which is completely free, and is much better than the Notepad or even Notepad++. The Dreamweaver is expensive unless of course you are downloading a one month free trial. The Netbeans allows you to write code easily quite same like Dreamweaver. The Notepad++ needs you to download some extra plugins to allow it add better support for PHP.

Share this post


Link to post
Share on other sites

Rather than installing the PHP yourselves, I suggest you install some IDE like Xampp, or Wamp, and they does make your job easier. Also do not try coding in Dreamweaver, as they shall generate the code most of the times with drag and drop, and that is not good. Better use Notepad++ like the rest of us.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×