How can I learn PHP

I want to learn PHP…

OK… go out and learn :smile:

I don’t see a question or any start to a discussion with your original post, you may want to elaborate on things…

2 Likes

Download and install something like WAMP on your local PC so you have an environment to test your code in. Then buy a book or look at some online tutorials, start slowly and work your way through. I always find that when learning a new programming language, it’s best to try to think of something you want to code and figure out how to go about it. For example I have a collection of old club magazines and frequently want to find an article or photo and can’t remember which one it’s in, so I wrote something to collate it all for me. I find I learn much more quickly than just working through someone else’s idea of an example. Different people learn in different ways though.

1 Like

SitePoint offers some really nice books on PHP, MySQL, the LAMP stack and so on.

Why not look for them online or in your local bookstore?

1 Like

Thank you all.

My first counter question will be - what are you trying to achieve by learning php. There are so many tutorials and so many different scripts.

Sometimes, a wordpress or joomla script will do 80% of what you want to achieve without learning code.

I don’t know much PHP myself, but I manage to do what I need to by searching for and example online whether its how to display text - echo “Hello World”; to something like _isset _get and using variables.

At the end of the day, it all depends on what you want to achieve, and hence this will determine how to go about doing it.

Happy coding.

1 Like

Thanks…

What is your application going to be exactly? If you just want to learn PHP so that you can have experience in a programming language, I’d say learn the basics first. You should learn what <?php does compared to <?= or <?
Then after that. Learn about the difference between print and echo. Then learn about requires and includes. Once you get the hang of it. Start learning other things like foreach loops, while loops, if statements, arrays, .etc.

Don’t go Google searching for examples though. I mean those examples are great to teach you, but there’s a lot of flaws. I’d suggest using the official PHP website. Everything there should be what you really need. A lot of tutorials don’t teach you the right way. They just teach you how to do it.

Example: There are tons of tutorials that teach you how to make an image uploading system. Question is. IS it safe to use? People can upload arbitrary codes into your website and poof. Your website can be hacked. Tutorials don’t tell you what to look for and what use. They’re just there to help you out. Not to protect you.

For a decent uploading script, I suggest looking for MIME type and then looking for the size of the file then looking for the width and height of the file. If it’s too big for your desire, you can limit it. Checking for MIME type allows you to avoid any arbitrary codes. If someone creates a .txt file and puts random codes into it and renames it as test.jpg. They can inject that into your website and hack your website. If you check for MIME types, the file itself will have the header text/plain even though the file extension is .jpg. This makes an easy way to figure out what is a legit file and what is not. Real images that are made from photo editing softwares will always and most likely have the header image/___. This will help you out a lot to prevent people from injecting random stuff into your website.

A lot of tutorials don’t even have MIME checking on there website. They’re just using an old fashion of checking for file extensions which is horrible.

Learning PHP isn’t going to be hard nor simple. If you really want to learn PHP and you are devoted to learn it. You’ll learn it. If you just want something to use whether it’d be good code or not. Then I wouldn’t suggest PHP for you.

My first exposure to PHP was O’Reilly’s PHP Pocket Reference (back when ver. 3.0 was in use)

My first code was this example

<HTML><HEAD><TITLE>PHP Example</TITLE></HEAD>
<BODY>
You are using <? echo $HTTP_USER_AGENT ?><BR>
and coming from <? echo $REMOTE_ADDR ?>
</BODY></HTML>

Wrong in so many ways compared to what it should look like today, but it worked and got me hooked

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.