I more or less know what each element does now but Im still finding it a challenge of thinking when and how to use them. I have a confident imagination but this is like stalemate!
e.g a response email script should have “a foreach, two if statements checking etc”, my brain is just not thinking like that lol
Is there perhaps somewhere that might be able to give me a basic anatomy of certain php scripts…?
Or some advice of how think like a programmer…?
Everything I have read and watched never really helps explain what elements make up what scripts or in what order
For example I still dont know why empty speechmarks are used!!! Perhaps it just me…
Empty speechmarks? You mean “”? Those are used when you need to define (or more often compare for equivalent) to a string with nothing in it (an empty string).
Unfortunately there is no silver bullet to help you make this jump. It’s usually the hardest jump for a programmer to make, and it’s just something that comes with experience.
To get you started though, there is a general process for writing a new script or program:
come up with the idea
flesh out the details of the idea (often disregarding the programming aspect, only worrying about the functional aspects)
break the idea into logical pieces (and this point now considering the programming, but only in a general sense)
figure out the code for each piece
if needed, break pieces into even smaller pieces
And that’s pretty much how to create a program in a nutshell. As you gain experience and understand more and more PHP, you’ll be able to make more educated moves, breaking into better pieces, making each piece more efficient, etc., but that’s something that comes with time and experience.
I’ve been programming since I was 10 years old (over a decade now) and almost every day I still pick up some new little nugget of information which helps me make my next program just a little better. It’s one of the main reasons I’m on Sitepoint every day.
By working out answers to people’s questions (questions I may have never even though of asking before), I gain new experience in something I may never have touched.
By discussing problems with other developers and experts, I may find an even better way of doing something.
And, by asking questions that I don’t know the answer to, I then learn the answer. =p
Hope that helps give you a little nudge in the right direction. If you have more specific questions, feel free to ask them. =)
Mmmm, nope, there are many ways to skin a cat, no two programmers will come up with the same program for a job (except in very simple cases)
Is there perhaps somewhere that might be able to give me a basic anatomy of certain php scripts…?
Nope, see above, every script you find on the net for same function will be written differently (or copied ), there are however many tutorials that will help you understand each instruction more.
Or some advice of how think like a programmer…?
Just hang around, nerdism is catching
Everything I have read and watched never really helps explain what elements make up what scripts or in what order
For example I still dont know why empty speechmarks are used!!! Perhaps it just me…
something inside speech marks usually is a string of characters … therefore by definition empty speech marks = empty string
Dont try to run before you can walk, set yourself a realistic project, say you example above of a contact form, once youve got that, try adding the data to a database, once youve got that make the script password protected … etc
Simple steps that will build your knowledge of each instruction.
I guess its all about taking my time and building up confidence. Im gonna follow your planning steps and see how it goes.
Just one quick thing, when you say empty speechmarks=empty strings can you give a practical example of when this will be used e.g on a form or something…? Are they left empty when users will fill it in client side ? (sorry if thats mind boggling)
Once again thanks for your help guys, Im sure Ill get there in the end.
For example a text input on a form that is then assigned to a variable, if the user doesnt enter a value on the form the variable returned will be an empty string.