Jump to content

Where To Start In PHP? I Think I Am Crazy


gobbly2100

Recommended Posts

I really don't get it, I understand the concepts of programming but I just can't seem to take it in.

 

I have been trying to learn PHP for almost a year now and I really can't do anything with it, I see some people who pick it up in a few weeks and it leaves me so confused.

 

I badly want to learn PHP but I just seem to fail and I don't understand why.

 

Has anyone else had this experience but overcome it?

 

I would really appreciate any help and advice because it is making me go crazy that I just can't make sense of it and make even the most simple of scripts.

 

Thanks in advance!

Link to comment
Share on other sites

For me, the trick to understanding PHP was understand the process by which a user requests a webpage and that webpage is provided to the user. If this part isn't bothering you, ignore my post, I hope maybe this will help you though.

 

When a user requests a webpage, they fill in the URL, hit enter, and their browser generates a request. The request is sent to the host server. The host server interprets that request, and then returns to them the file they requested.

 

For typical HTML, it's that straight forward. The server finds the HTML file they want and then sends their browser the HTML file (there's actually more going on, headers and the like, but don't worry about that at this point).

 

PHP simply adds another layer of complexity.

 

When a user requests a PHP file, the server recognizes that the PHP file contains code. The server executes that code. PHP "writes" what the server is going to respond through primarily echo commands (actually, there's a lot of commands that write to the browser, but echo is the most basic). PHP is generating this response "on the fly" (that is to say, as it's run, the response isn't stored somewhere, PHP literally writes the response to the server's memory, and then the server sends that response when PHP is done) or, as it's more commonly known, dynamically.

 

The simplest of PHP scripts:

 

<?php echo 'Hello world!'; ?>

 

...do the exact same thing that a simple html file with the 'Hello world!' text would do.

 

Through PHP's command structures (if - then statements, loops like a while and foreach) you can change what PHP writes to the browser. As an example, you could tell PHP to say 'Good morning world!' if the time is before 12pm, and 'Good afternoon world!' if the time is 12pm or later.

 

With PHP in the mix, a typical webpage request looks more like this...

 

User requests a PHP file, the server executes the PHP file, the PHP file puts into memory a response, the server sends to the browser what PHP wrote in it's memory.

 

In this way, PHP becomes a very powerful tool. It's not even limited to HTML files. PHP can send headers that allow the browser to recognize anything it's capable of recognizing. PHP can write PDF's, images, Flash content, tons of different things, and then send that to the browser.

Link to comment
Share on other sites

It really depends on the way you are learning php and if you have previous experience with other programming languages (or at least you are good at maths).

 

like anything else in the world, practicing the main key to learn php. For a start try to download light open source programs that really do basic operations, then try to add something to it. Forum like this one and many others exist so people can exchange experiences, ask questions and get answers so do not be afraid to ask (or search if you think your question is simple).

 

If you can master small scripts then large scripts will not be an issue since they follow the same logic and apply similar principles only on a large scale.

 

hope this helps

Link to comment
Share on other sites

I agree that having a working server on your local computer is a necessary requirement. There is nothing more off-putting then having to upload your file each time you want to change a semi-colon. I use xampp personally, and it works great.

 

Take a look through a lot of examples and tutorials. There are some great tutes out there that explain in depth how things work.

 

Dont jump too far into things. Get used to if/else/while etc before you attempt to learn classes, or write a forum for example. mysql is also a valuable addition, but make sure you have the basics of php down pat first.

 

 

Link to comment
Share on other sites

I really appreciate the reply's guys and taking the time to write lengthy posts.

 

I do have WAMP installed and to explain further, I can get my head around the idea of else if but it is the making it functional part and especially using databases that throw me.

 

Are there any good small scripts that you have as a suggestion to play with?

 

One thing that I find annoying is knowing how much I "could" do with PHP which makes it harder to stay motivated with the very basics, any tips for keeping concertration with learning programming?

 

Again, thanks for the posts!

Link to comment
Share on other sites

To me the "main" function of PHP is reading/writing to a database. In other words, use it to store some stuff, edit some stuff and delete some stuff (very elementary, but hey you are still learning, just like me).

 

Take a look at: http://www.freewebmasterhelp.com/tutorials/php

 

Then google for a simple user management system tutorial and try this. The main parts would be add user form, login form and check user code. Then extend it to allow you to delete and edit the users in the database.

 

It might seem superfluous at the moment, but once you have what I mentioned above under your belt you can make MOST things in PHP (well the things I use anyway). It might not be pretty code, or the most efficient (ie using classes) but you can do it.

 

Also, make sure you have a pretty good handle on HTML first.

Link to comment
Share on other sites

Before looking behind the scenes at the code of a content management system and getting into the complexities, I suggest you install one locally and play around with it so that you can understand the processes in which content is dynamically added and changed/removed.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.