Jump to content
Larry Ullman's Book Forums

How Do You Learn To Really Write Php By Yourself?


Recommended Posts

Hey guys,

 

I finally got around to finishing a large part of the book.

 

I make sure I understand everything 100% before moving on to the next chapter. But even when studying like this, if I'd just come up with something I'd want to make in PHP and it isn't mentioned in the book, I have absolutely no idea how to start working on it.

 

Sure if I had no idea how to make a calculator in PHP I could always just google a script/tutorial for that, but if I couldn't do that I would have no idea where to start. Obviously there's harder or custom things that need to be made at some point aswell, and at the moment there's not a single thing I would be able to code on my own that isn't mentioned in Google or the book.

 

So my question is: How do you achieve that mindset in which you're able to recognize which kind of code you have to use to make a specific webapplication/function ?

Link to comment
Share on other sites

Programming is all about actions to data. When you have been programming for a while, you can identify that you need to do this and that to the data to achive a result.

 

To take your calculator example. What does a calculator do? It computes answers out of operations performed on numbers, right? That's a pretty abstract description of a calculator, but it's a start. We must then decide what operations, actions, this calculator should be able to perform. Let's say we want to able to multiply two numbers, how can we code that?

 

Let's make a simple plan:

1. We need a form with two HTML input fields.

2. We need to make sure the form is submitted by the user

3. We need to make sure both fields have valid values

4. We need to display error messages if not

5. We need to calculate the answer and display it to the user.

 

This applies to all programming. My first programming teacher forced us to always write down all steps needed to achieve the wanted result. I think you should do the same. When you want to solve the problem, sit down and write a step-by-step plan on how to solve it. You don't need to follow that plan in the end, but you'll begin to see that planning pays off in the end.

 

Hope that helps a bit.

  • Upvote 3
Link to comment
Share on other sites

The way most websites work these days is similar, so starting of with the PHP and MySQL as you are doing is a good start. You could start by trying to build parts from certain pages of your web site and getting them to work. If you are missing or unable to build some features into your web site it may be because some of this code is written in Javascript. Javascript deals with client side scripting where as PHP is server side. If you can use Javascript it means you can update things on the page on the fly without having to reload the page, that's the best thing about it.

 

To be able to implement PHP and javascript well, you also need a good knowledge of HTML and CSS, HTML is easy but CSS requires a lot more work, you can purchase something like a CSS design patterns book to help you with some of the difficult stuff.

 

But lastly once you have learned the other things i recommend learning a framework like YiiFramework as a base for building your website into, this will be tried an tested, so you don't need to worry about bugs coming up later on, it gives you maximum time for development and lastly saves time reinventing the wheel. YiiFramework is awesome as it using the lazy loading technique its also faster than and more efficient than other frameworks on the market. You may have heard of ZendFramework from the makers of PHP but my advise to you is stay away from it, its absolutely horrible. I would also recommend using the JQuery Javascript framework as an assistance in your web design.

 

But seriously about 1.5 years ago i was asking the same questions like you, i bought book upon book until i come across Larry's books, i have read through his series and now i can say that as soon as i have leared his Yii book, i can build anything i need now. Believe you can go out an buy other books like I done but you won't find any books better than Larry's.

 

Also being through a Large part of the book is not enough, you wait till you get till the last 3 chapters putting it all together, then you will start getting the idea on where to go. Its just about keeping patient and going on through these books and it will all come together nicely, trust me you stick to these books and you will be sorted.

Link to comment
Share on other sites

Going from understanding Larry's code to being able to start with a blank text file and make your own site is a big leap (and probably the most important leap of all). I remember thinking the same thing a few years ago, and while I can't remember exactly how I went about making that leap, I think it comes down to three things: practice, practice, and more practice.

 

Try to find something that you're passionate about that will allow you to flex your web development muscle, and use every web development tool you have to try to reach a goal. Through the process, you will learn a lot. Then, once you have the basics down and the general ability to create something on your own, you can start focusing on specific things and refining those skills, one by one.

 

Good luck, and enjoy the journey (which never ends, by the way; the more you learn, the more you will want to learn).

Link to comment
Share on other sites

Sorry for the slow reply guys, and thanks a lot for your advice. It's good to know I'm not a natural failure at php.

 

I have 2 more questions if you don't mind.

 

1. Do you have any ideas on how to get myself to practice more? I have a hard time coming up with ideas that i can turn into a project.

 

2. Do you guys have any special software you use with php coding? I currently use Eclipse but the auto-completion confuses me a lot and calls for lots of debugging once a long file is done.

 

Thanks again!

Link to comment
Share on other sites

I'm pretty adamant about the "natural" way of coding, which means I prefer to stick with base languages and avoid frameworks and code-assisting tools as much as possible. Of course, I acknowledge the usefulness of frameworks and whatnot, but as much as possible, I try to avoid them.

By coding things using only the base language, I think you learn faster. That might be something to consider.

 

As for ideas, take a topic you're passionate about, and make a website for it. While you're at it, whenever you go to another website and see something cool that you want to include on your site, study that code and figure out how to do it, and then do it. That's how you learn.

 

Of course, whenever you're stuck, you're welcome to come around here and ask.

Good luck!

Link to comment
Share on other sites

As well as creating a site about a topic you're interested in, you could create your own site which would include your portfolio (just make it up initially), a blog which you hand code rather than using something like wordpress or joomla, a contact form, social media links and an xmlfeed. Other ideas are to do some sites for local charities or community projects.

 

Regards software - I use a basic text editor, TextWrangler. It provides colour coding for different languages which is very useful. I've heard very good things about TextMate and keep meaning to have a look at it.

Link to comment
Share on other sites

Thanks a lot for your advice guys! I really appreciate it a lot.

 

I'll try/study every piece of advice you guys have given.

 

Hopefully it'll get me a lot further in coding so I can eventually start HELPING instead of asking on the forums!

Link to comment
Share on other sites

  • 1 year later...

I've just finished the first part of a website built for a non-profit organization to which I belong. Talk about a journey! I've spent hours and hours, as folks say pulling my hair out, trying to figure out why something isn't working. I finally give up and go to bed, and then wham . . . I suddenly think of something I hadn't tried, and I climb out from underneath the blankets and sure enough, there was something wrong--usually a stupid typo--in the code that caused the problem. As soon as I see it's working, it's like I'm on top of the world, and all of the frustration and confusion is worth every minute for that high! I think I'm addicted!

 

I've worked through this book and Larry's first book on PHP three times now. Every time I work through them I learn more. I don't know how I missed some of the stuff I missed, but there you are! I never use the files he provides, I always type them myself, and that's probably why I have so much trouble. But it forces me to look more carefully at the code, and to try to understand it more thoroughtly, I think.

 

I worked for a PHD Stanford graduate in California for awhile, and he made us write programs in comments before we added code. I think that's a good way to see if you have what you need to pull it off. The truth, he used to say, is in the algorithms.

 

I bought one none-Larry book, David Powers' PHP Solutions, and it doesn't come close to being as good as Larry's. My next project is to get Larry's advanced PHP book, and I bet I'll work through that five or six times.

 

I still have sections to add to my non-profit's website, but I'm so happy that I got it up and off the ground. I'm sure you old pros know 100 times more than I do, but I have to say that given how quickly things change in the field, you'd be crazy to consider yourself done with the learning.

 

What in the dickins is yii? I'll just have to find out.

 

One final thought for someone who might be feeling discouraged as I was a few weeks ago. I couldn't get the registration system to work for my non-profit's website. I chose iPage for my hosting company because, frankly, they were the cheapest I could find. Well, I'm sure it's true that you get what you pay for, but it has worked out OK for me. I could not get sessions to work, and I went to the iPage knowledge base and searched for sessions, and discovered that I had to modify the PHP.INI file ON THE SERVER. Yikes! The path I discovered I needed to enter was goobledegook times ten. But I struggled through, and I got it done. And when I was able to access the session data I felt like a million bucks.

 

Larry, for an English major, is fantastic at helping people through this maze. He is the man.

  • Upvote 2
Link to comment
Share on other sites

Great post and great story.

Thanks.

 

Getting that first site going is always hard, but if you're like me, you'll be hooked and never look back.

Also, I totally know what you mean by that high you feel when you finally get something working that you're stuck on forever. It's a great feeling.

 

As for new stuff to learn, yeah, there's always something new to read about, but after a while, you do begin to plateau in your knowledge, and you realize that must new stuff is more just a slightly different view on the stuff we already have.

 

And as for Yii, Yii is a PHP framework (and seemingly a pretty popular one, at that). Larry is the premier Yii writer, so you should definitely check out his Yii book, if you're interested.

 

Also, I agree with what your PhD boss said about the truth being in the algorithms. The algorithm are ultimately what make a site a site; what give the site substance. Everything beyond that is just basic interface stuff to make the info on the site more easily accessible.

 

Anyway, thanks a lot for your post. It was very interesting and I think very beneficial to people that are still starting off.

Thanks.

  • Upvote 1
Link to comment
Share on other sites

 Share

×
×
  • Create New...