Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have this idea for a website that's been floating around my head for quite sometime now and now have finally decided to get to work on it. Due to the nature of the project and my experience I am getting comfortable with the idea of running it as a PHP+MySQL application on an Apache server.
This is my first time doing web programming of any sort(I have a background in sysadmin and mainframe systems coding) and I am pretty unsure of what practices to take into consideration so that I don't find myself undoing/redoing things later in the project. Considering all the flak the language has taken on StackOverflow(which can be seen here and here) it would be nice to have a set of common mistakes to watch out for for a beginner like me. I did find this thread outlining things to avoid in PHP but most of the points made little sense to someone like me who's just setting out in PHP.
Do you have any suggestions, tips or tutorials outlining common gotcha's in the language which might come back later in the project demanding entire rewrites.
For what it's worth I am currently working my way through Programming PHP(O'Reilly) and PHP in Action(Manning).
I was in a very similar position a couple years ago, having come from a NOS background myself.
I actually started with PHP and MySQL for dummies. Once I had absorbed the knowledge contained therein, I hit the Web (I used SitePoint a lot, like Boushley recommended) and I read a couple of O'Reilley's book on the subject.
Once thing I will tell you, is that if you want to streamline your understanding and your efficiency, I have found great success with a number of MVC frameworks(CodeIgnitor, CakePHP, etc). If you have no idea what MVC is, I recommend finding out. Now that I use MVC, my code is easier to understand, modify, troubleshoot, etc.
And honestly, half of the learning in PHP is running into those common mistakes and learning from them. Its hard to appreciate those 'common mistakes' until you make them.
Don't worry about HOW you are going to learn, just START leaning!
If I could give you one piece of advice, it'd be to use a framework - they will make your life so much easier. They take away all the repetitive code from programming websites, handle security concerns and abstract lots of things, as well as make you build your website using a pattern such as Model-View-Controller.
I highly recommend the CodeIgniter framework for it's simplicity, power, great documentation and ease of use, but there are plenty of other good frameworks too. There are lots of questions on SO on this so have a quick search. There is a fantastic introductory screencast on CodeIgniter (soon to be a series) from BinaryCake, so check that out here.
I hope that's helped! If you have any PHP concerns, feel free to message me - it's my area of expertise (along with CodeIgniter) and I love it!
While still developing, have all errors show up:
ini_set('display_errors', '1');
error_reporting(E_ALL | E_STRICT);
Can save a lot of time (in case of say, typos in variable names). Change this when it goes live to not display or only display "real" errors depending on the type of site and security levels involved (you don't want everyone to know paths and variable names and such..).
Find a variable/function naming convention (under_scores vs camelCase vs..) that suits you and stick to it. Also, classes go in the /class directory, includes in /inc etc. Both these make it easier to understand your own code years from now. Oh, and the same goes for coding style, I guess: choose one and stick to it (indentation, bracket style, ..).
Comment your code :-) Personally I also have a little log at the end of longer files that shows when I did what and why. Each addition is timestamped, and the same timestamp is also in the comments behind the change itself, as the line number on which it sits can easily change. Similarly, in an included file containing a bunch of functions, I have the list of function names in a comment at the top of the file, with a one-line description behind them.
Finally on security (though this should really be your first concern ;-) ), treat all user input as suspect. That's POST & GET data, cookies, user-agent string, search strings - anything that is supplied by the browser. It's trivial to change cookie data or change/add form items.
Read up on SQL injection & XSS attacks, and look at PHP's relatively new data filter functions: http://php.net/manual/en/intro.filter.php
Google any of these to get some good reading
Don't use register_globals
Turn off magic_quotes - escape all user entered input in SQL statements
Escape any user entered input printed with htmlspecialchars()
Plus a lot more... These are some common things to watch out for though.
There are a number of great websites out there with lots of tutorials. One that comes to mind is Site Point. They'll try their best to sell you a book or two while your're there, but they do have some decent articles. This article for instance discusses some common security blunders in php.
http://www.sitepoint.com/article/php-security-blunders/
They have lots of them...
http://www.sitepoint.com/search/search.php?ps=10&q=php&submit=Search
Also a nettuts.com has a load of tutorials an things of that nature. They're more all across the board though.
http://nettuts.com/
And I think pretty much everywhere you look you'll see the common ones like watch out for register_globals, magic_quotes...
one good book to look at that is also free to download here covers beginner to advanced PHP techniques and is good way to learn good standards :)
Use a framework and use Object Oriented Programming
Books are great for learning additional languages, but for your first one, a good video tutorial is a great way to go!
Register for a Lynda.com account (google: lynda trial) and sign up for as many one day trials as you need (or be a good honest person and purchase a week). They have a pretty good beginner and advanced PHP series of video tutorials which are (IMHO) a great way to learn your first language.
A tip: If you can start programming Object Orientedly from the get-go, you will save some time in the future and learn good practice from the start, luckily the advanced tutorials cover this!
Here's a link: http://www.lynda.com/home/DisplayCourse.aspx?lpk2=435
I've never taken this particular course (when I learned a few years ago, it was different), but I just recommended this to a friend (who was just starting), and he really liked it!
Hope this helps!
If you're new to programming in general, A database backed web application is likely to be a bumpy ride. You will probably be programming in at least two, real programming languages, PHP and SQL, and if you're going to do anything of modest complexity, JavaScript too. Keeping them strait will be rough, because they are all quite different.
Just to warm up to programming, you might want to start instead using a more focused learning excercies, such as working through the Euler Project problems, or Code Kata.
Either way, Try to pick up good habits wherever you learn about them, including the popular suggestion here of using an MVC framework for the heavy lifting.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
It's not hard to find example PHP code. The problem seems to be that most of it is frameworks/libraries/etc. This is great, but I'd like to see an example of an actual website.
This stems from my perception that I can't build anything but "toys." My websites tend to be fairly CRUDdy, and it feels like my sites are a bit of generic MVC stuff and a lot of "SELECT" and "INSERT" statements.
I just want some assurance that I'm not "doing it wrong" since these are personal projects, and I'd like to use them to get a job.
Below is a good site that also make its source available (which is very well commented and easy to follow/understand, from a Zend Framework standpoint)
http://www.dasprids.de/
Instructions/info for the source
http://www.dasprids.de/behind-the-site
Actual source
http://site.svn.dasprids.de/
Check out MediaWiki. That's the same software that runs Wikipedia, and it's open source.
It's worth noting that the php.net website is itself open source.
What about PHPBB, which is neither a framework, nor a library?
There are also plenty of Open Source websites you can find just by making some search. Especially blogs, content management systems, etc.
Edit: responding to the first comment to my answer, I want just to add that looking at Open Source websites would probably help to have an image of what large (or not so large) projects are, and also how things are done by experienced developers (for example using PDO, SQL transactions, templates, etc.).
But please take in account that most of the time, those projects are developed by several people. And since PHP does not have any coding standard and does everything possible to force the people to not use good practices, large, collaborative projects are not so good at improving your coding standard nor learning good practices. For this, books may me much more helpful, especially books about good practices.
It may be worth looking at wordpress. I haven't looked at the php behind it, but I know I learned a lot looking at the DB definitions.
Usually a framework is a good compromise between writing quality code and performance. Larger websites that need scale come up with their own custom hacks which eventually evolve into frameworks. In my experience writing in pure PHP it's too easy to go the quickest way to implementing a feature and end up with a mishmash of code, but others might be more disciplined.
It's not hard to find example PHP
code.
Good point is that you know how to find code. You said your code ends up in a generic MVC and CRUDdy, i think this is what most of the web applications around are doing. But the important thing to consider here is they do these MVC/CRUD stuffs in managed way and following standard Object Oriented Design Patterns.
If you want to get examples of real PHP applications then search for open source codes for that specific type application and not frameworks/libraries. Frameworks/libraries are a bunch of PHP CLASSES combined together following the application design architectures and they are supposed to provide you a code base to start your new project with existing set of usable codes, not that they give you the "application feel" rather "structured feel" at the starting point. But once you get along these frameworks/libraries working together to provide you a structured way to build your application, things will really ease later. Your job is guaranteed ;)
If you want to develop codes with these MVC frameworks then start with Codeigniter. It is well documented and as you stated your existing code turns out to be like MVC, you'll grab this framework and how to build with it in one shot. I've written a Hello World in Codeigniter you can refer to start with it. (Also Refer: Codeigniter Documentation)
To find code for real application (not frameworks/libraries) you might think of slightly changing your search queries, search for categories of web application or alike you want to see, not just for the code to do this and code to do that, always search for the better and efficient ways to code and develop things. Github, Sourceforge.net, Google Code are really great places to search for "real" & "cool" open source PHP applications.
Well, actually you can learn a lot by studying a solid framework like ie. the Zend Framework. If you would like to learn that I suggest you first have a look at the Zend Framework Quickstart and then start reading Surviving the deep end. Once you covered these, you should have learned the basics of the Zend Framework, and then you can start looking at open source projects that use it. As far as CMSes go, there are a few using the Zend Framework, like TomatoCMS and pimCore.
BTW Creating a website isn't exactly rocket science, most sites are in fact just a collection of dull CRUD screens (sometimes spiced up with some AJAX to deliver a better user experience) that are used to add content to the site...
On beta.mkforlag.com, where I try out new ideas and develop new pages and new layout for the main domain, most of the source code can be seen. Most of the site is in Swedish, but most of the php code (comments, variable names etc.) is in English.
You should also keep in mind that although I've been using PHP a couple of years I'm no PHP expert and most likely "doing it wrong" in many cases. If you're not that advanced, though, you may find at least some of my code useful.
My code of satya-weblog.com is almost live. I am using wordpress V 2.9, so download that and you know about my site!
Check at symfony framework also and you come to know of propel, yml etc
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I tried doing tutorials but it is unorganized and unstructured, where can I learn PHP from beginner to master? I'm looking for a site like www.w3chools.com, but somehow I feel it is incomplete, specially when it comes to more advanced functions.
I know some basics but I wouldn't be able to for example make a secure online webstore, and I seem to be stuck at this point, how / where should I proceed?
I started 7 years ago. In my personal experience, your road to programming will look something like this:
HTML -> CSS -> Javascript -> PHP/MySQL
[Insert other web script language
here] -> "Desktop Languages"
For HTML (and CSS), I started by using a graphical editor at (then freewebs.com) webs.com that allowed me to add code snippets. I used some random GeoCities site (may it rest in peace) to look up things. Now, use Google or Bing.
Then, I got Jeffrey Zeldman's book, Designing with Web Standards. I followed through the book, typing out the code in notepad. Try to understand what the code does.
Do yourself a favor, use Notepad++ or Programmer's Notepad. They support automatic tabbing for neater code. It will make you a better and more sane coder in the long run.
Another thing I used to do was look at people's code by right clicking in my browser and hitting "view source".
This only gets you the HTLM/CSS after the PHP has been run and the Javascript before it was run. Google Chrome is good for analyzing scripts because of the debugging capabilities. (Don't worry about that yet though.)
Javascript was an adventure back then. Now, we have jQuery. Start with that or a similar framework. This can be researched online. I have never bought a Javascript book. I do have an ancient one from Visual Quickstart that I used to learn what a method looks like. Beyond that, the particular book in question is
an outdated rag.
To learn PHP/MySQL you can get a book. The two languages are often put together so finding books that show you how to use them in tandem should be a snap. I used O'reilly books for PHP.
I don't like the online PHP reference so much, because when I'm testing I don't always have internet. I use a virtual server setup on my machine. Look into that when you are ready to start learning PHP and MySQL.
The last thing to remember is that web standards are always changing, but don't get too crazy about it. when I started, XHTML was all the rage and now everyone is talking about HTML5. I still use XHTML as do many others. It goes to show that things move at different paces for everyone.
Good luck, I hope I helped!
EDIT: Geoff Adams pretty much sums up my post - Play around the invest in books. And, it will take time. I'm till nowhere near perfect.
Getting to 'mastery' is going to take a lot of effort, time and work. You can't become an expert by simply reading tutorials - the best way is to learn by doing. Get to grips with the basics, then play around. Once you're more comfortable, invest in some books.
If you're looking to build a complex system then you might be better using an off-the-shelf alternative. Try Googling around for various e-commerce systems (Magento is in vogue at the moment) and Content Management Systems (CMSes) before you decide to reinvent the wheel.
Read this book
also keep going through those tutorials (XHTML, CSS, Javascript) and try out everything you learn as you learn it.
I love the apress books so perhaps Beginning PHP and MySQL: From Novice to Professional, Third Edition might be for you? Do you have a development background?
You may want to look at picking up a book at your local book store or look at grabbing one off Amazon.com. I haven't found really good PHP web resource to learn from. Usually I just do a quick google search on topics I'm trying to code.
Another option is to just dive in and start building applications. I've found that the best way to learn PHP is to learn as you go. Once you have a grasp on the basic syntax and how to move around the code, then you can pick up a book at look at OOP topics as well look into Frameworks such as Zend, CakePHP, etc.
Are you absolutely set on learning PHP? If you are, then buy a good book - there's several mentioned here that are actually ok - but please, learn the security aspects from the start. There's more than enough PHP developers in the world who are writing insecure code (I used to be one of them, so I'd know).
Practice is key though; I've been programming in PHP now for about 6 years, and I'd consider myself fairly competent (I passed my Zend PHP5 Certification a couple of months back), but I still find functions I've never seen before.
A tip - don't even think of looking at Zend Framework, Magento or anything like that until you're comfortable with the basics. If you do, you'll definitely struggle; they use some advanced concepts which even I find it hard to wrap my head around at times.
Alternatively, you could learn something else...
The book recommendations are great. "Mastery", though, comes only from practicing your craft. If you want to learn PHP, you need to build many sites, with PHP (and HTML, CSS, Javascript, MySQL, etc.).
To have confidence that you can build a secure online web store, well, you need to build one. Maybe you can find a company that will pay you to learn. Maybe you will find a colleague to mentor you through it. Or maybe you'll have to dig into books, multiple web sites, and some poorly written "integration guide" from a payment authorization provider. My first time through I was nervous. The second time it went a little quicker. And the third time I felt confident enough to estimate how long it would take.
I'm not trying to be difficult or flip. I just feel that "learn by doing" may be the only way to learn much of this stuff.
Apologies if this is not the right place to ask but here goes...
What should I use to create a simple web application for our website?
I'm the IT guy for a small non-profit. On our website we have a page with a large form in which users can fill out information on an application form. The information gets sent to a MySQL db. This data can then be accessed and edited by a couple of members of staff behind a logged-in part of the website. There's only two dbs being used: the main one with all the data and the one used for login details for the web app. It's all done with PHP and functionally is fairly simple - just a form with lots of fields to collect data and a basic secure "manager" page to do a bit of stuff with that data.
The problem is that we need to make changes to the app, and to extend its functionality quite a lot. I have a little bit of experience playing around with PHP but I've taken one look at the code used and decided it'll take too long to decipher it and see what's happening where. The code is uncommented and a bit of a mess.
I'm starting to think that rather than investing time to relearn what little I knew about PHP and untangle all the code, I might invest the time in learning another language and/or framework to get this done. I want the resulting web app to be a lot easier to maintain in future by me or anyone else who comes along and has to make a change.
Would you recommend using Django/Python for a project like this? Zend/PHP? Just PHP and notepad? I want the app to be done fairly quickly so the less steep the learning curve the better. Many thanks for you time.
Another good PHP framework is CodeIgniter.
They also have a good webcast that outlines how to begin with the framework as well as create a simple blog [tutorial].
I would recommend a PHP framework, such as CakePHP. Spend 20 minutes of your time and follow their blog tutorial.
Using PHP alone can be tricky, especially when you will have to deal with security issues.
From what I can see you have asked 2 questions.
1. Should you maintain and extend the current code base or do a rewrite?
Rewrites always take longer than you think. And even if you do the rewrite to avoid learning the codebase you would still need to learn the current codebase to ensure you capture the current functionality before adding any new features in the rewritten codebase.
I would keep the current codebase and maybe do some refactoring as you add features.
What should language and frameworks should you use?
I would stick with PHP, CakePHP is a solid framework and so is Zend. I would read up on both and do a couple of tutorials and make your decision.
As Anax states, I'd suggest that you look to use PHP. If code is already implemented then you have a start.
PHP isn't hard to re/learn. I know some don't like it, others like it but simple fact, either way it isn't hard to learn. But, more importantly consider the following:
You obviously have access to the hardware stack required to use PHP and MySQL. Introducing a new language/technology may cause unforeseen issues with getting a production site set up.
Now this doesn't mean that you can't write certain components in other languages. You could, if you were so inclined. But you probably shouldn't be so fast to get rid of PHP just to learn another language. Do you have important (technical) compelling reasons to use something other than PHP?
If you are mostly concerned about the spaghetti code in place, you can get that anywhere -- even new development. Better to re-factor the code and fix and add to what you have than start from scratch.
I can offer some general considerations:
Whatever language you choose, get a good IDE for it. Having automatic syntax validation and code completion helps a lot if you're a beginner. Don't use plain text editors.
Teaching yourself how to code well will make for a very frustrating experience unless you have a lot of patience. This generally comes from being really sure that you want to do it.
Be very conservative in your time estimates. Having many setbacks is guaranteed if you're a beginner.
Start out by focusing on reading about writing code, not focusing on writing code. If you're learning Python, read the official tutorial first. The same goes for PHP.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
The question has been asked: No PHP for large projects? Why not? It's a recurring theme and PHP developers--with some cause--are forced to defend PHP.
All of these questions are valid and there have been some responses but this got me thinking. Based on the principle that you can write good code in any language and bad code in any language, I thought it worth asking a positive rather than negative question. Rather than why you can't, I wanted to ask how you can use PHP for large projects.
So, how do you write a large, complex, scalable, secure and robust PHP application?
EDIT: While I appreciate that the organizational aspects are important, they apply to any large project. What I'm primarily aiming for here is technical guidance and how to deal with common issues of scalability. Using an opcode cache like APC is an obvious starter. Cluster-aware sessions would be another. That's the sort of thing I'm getting at.
For the most part, the problems with php are not so much with the language. The problems come from the coupling of a low barrier of entry and the lack of any infrastructure to avoid common programming problems or security problems. Its a language that, by itself, is pretty quick-and-dirty. Nevertheless, it still has many advantages for large-scale web apps. You'll just need to know how to add in some level of infrastructure to avoid a lot of the common web programming blunders. See - What should a developer know before building a public web site for help with this.
You need to learn about the reasons php can make your web app to be insecure or problematic and learn to mitigate those problems. You should learn about how to use php to securely access your database. You should learn about avoiding SQL injection. You should learn about evil things like register_globals and why you should never ever use them. In short, you should do your homework about your tool before just diving in for a real-world, large-scale, web app.
Once you are educated, it comes down to you'll probably want to build a framework or use a preexisting framework that will mitigate these problems. Popular frameworks include PEAR and Zend.
Also, useful questions that might help:
What should every php programmer know?
What should a developer know before building a public web site
Using PHP for large projects isn't different than with any other language. You need experience and knowledge in writing maintainable and extendable source code. You need to be aware of security pitfalls and performance concerns. You need to have researched your problem domain and be well familiar with it.
In the end, same as any other language - what you need are high-quality and well-motivated developers.
i know, this is a little out of date, but still, i'll tempt an answer ...
use Haxe/PHP ... i could delve into details ... but if you look at the language, its features, and the nice way the PHP API is encapsulated into something rather consistent, you will soon see, what PHPs problems are ... and also, you have all the benefits of Haxe in the end ...
edit: this was a serious answer ... Haxe/PHP automatically solves a lot of problems mentioned in the post flagged as answer ...
register_globals is turned off ... you get your parameters through the php.Web
using the SPOD-layer (same API for php) for the database automatically takes care of escaping (and will automatically provide your model (and templo is quite a good template engine, so that should help for your views))
having a typed language, you are more likely to write better code ... plus language features as generics and enums are very powerful ... and there is a lot of compile time magic in Haxe that is also of interest ... a more powerful language is always good to adress complex problems ...
if you want to use other PHP frameworks, you only need to write the external classes and everything will work as expected ...
i think Haxe is a very good answer to "large", "complex", "secure" and "robust" ... scalability does not come from Haxe itself of course ... but still, if you check out haxelib, then you find many things, that would help for scalability ... such as memcached (you will have to change neko.net.Socket to php.net.Socket in memcached.Connection) ...
if you really want to use the PHP language, and not just the platform, Haxe won't help you of course ...
You do as you would in any other language or any other enviornment.
There are a couple of simple steps in project development:
Organization; You need to organize everything, having documentation, uml diagrams and other pre-work done, before you start programming.
Structure; Before you start coding and also aftter starting, you need to have a focus on structure, meaning that you always need to do it correctly and not do any spagetthi solutions. Keep code simple and well commented.
These two points, are simple and apply in all development areas, despite the language. Keep it simple and well documented and you will find that developing a large scale web app in PHP is as easy as it would be in ASP.NET, Ruby or whatever.
However when we come to the development stage, you need to get a nice IDE, use a good database, use a repo., get an MVC / Template system, this runs in the "Structure"-part though.
Just as a side point, splitting the application into different layers: DLF ( Data, Logic, Front ). Use at least these three layers and you will find that the development will go easy.
Use Model-View-Controller framework. It's been said, yes. And, have at least one engineer for each part.
Model: Your DBA should write the Model code. No should else should be allowed to write SQL statements.
View: The one with the best knowledge of CSS and Javascript should do the view part. He/she should write the least PHP code, he is the one using PHP variables.
Controller: She's the real PHP coder, and also back-end server engineer, hopefully, with or without using other script languages.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I myself am one of these types of coders, who never learned coding in a formal setting, but am instead, self-taught by the use of copy and paste scripts, and pre-authored works available through GPL projects and premium software's(which is often the way commerical script companies show you how to change, or update code in their script ie. "Copy & paste this on line 234, etc..")... this are my beginnings.
I don't understand how what I do works, but I am getting good at what I do with code, though I feel because of my informal learning methods, that I lack in knowledge, some of the really simple, but necessary principles of web coding in general(the ins and outs of servers, browsers, etc). I feel as though I have started from the inside of understanding code, the practical side.. and lack the basic fundamentals, and theorized understanding of what I am doing.
I also know quite a few others who are the same, who started learning in the same communities as I, and are pretty much at the same point as me... Feeling as though something big is missing from the picture.
I see the lacking in my discipline when I attempt to use PHP authoring tools, which I find very challenging to understand... and this is becoming a downfall on the time frames in which I complete my projects(having to hand code everything). I also find it difficult to ask for help at times, for lack of the specific language that comes with programming, and being able to use the right words to explain the intricacy of my problem.
I was a hairdresser by trade, I worked as a bartender, and hotel manager, I'm a business consultant by profession. I've been learning web development slowly now for 3 years, and I have taken on quite a few commercial projects over the past 2 years, but I'm obviously feeling some lacking in my skills & overall knowledge.
Basically, Id like to ask any experienced coders who've had similar beginnings to give me an idea on how I can adapt my coding disciplines to be more effective and productive. What would someone with such an informal understanding of programming want to seek to learn, and understand. What are the things I must know as a programmer... and what is a basic overview of the whole picture???? Feel free to direct me to articles
Any help is always appreciated.
Lea
Edit: Just to give a round up of my actual capabilities. I am a programmer, I do author my own code from scratch.. and sell my work. I can write PHP functions, and classes, use mysql, have a good working understanding of html & css, and am very good in the design aspects(web graphics), and am learning javascript/ajax/jquery, as I am using jquery in most of my projects. Thanks for all of the answers so far!
Realise that "copy and paste programming" is not actually programming, despite the name. The act of "programming" is figuring out how something should work, and what code is needed to make that work. Therefore, when you copy and paste some code, it is someone else who did the programming. This isn't a bad thing necessarily, as you shouldn't always need to write code yourself. But to call yourself a programmer, you do need to have written the code yourself.
You will want to start humble. Don't try to write a large complex application as your first step into programming. There is a good reason why most people who are taught programming are first taught how to print "Hello, world". This is because there is a lot more that you will need to know than just what code to use - you need to know where code execution starts and how it flows, and that sort of thing. You need to be able to look at the code and step through it mentally, knowing where program execution will go next, so you understand how it will work.
Take a tutorial or course in programming. There is so much free stuff online. Do not trust any tutorial that just gives you large chunks of code, make sure it forces you to actually come up with some code yourself. Do exercises such as sorting strings, calculating fibonacci sequences, and the like, and "echo" or "print" the results. Learn about conditional statements (like "if") and the "for" loop and play with these to do various things.
GUI or forms programming is more complicated; make sure you know the fundamentals of the language before you go looking through any API or framework documentation to see what the language can do. You'll need to know how execution flows, how to write functions, what types of variables you can use etc before you can effectively use an API or framework anyway. It is boring not being able to do cool graphics or forms and sticking to basic text or number processing, but you have to walk before running. Make sure you are doing, not just reading. When you learn about something new like the Array type, the "while" statement, try it out. By actually doing it, you'll "get it" a lot faster than just reading a book or website and you may be more likely to remember it.
Read books about programming. Some people say you should learn C before you learn anything else. I don't necessarily agree, but if you do learn C then the book to read is "The C Programming Language" by Kernighan and Ritchie. Many programming books are very interesting but either not suitable for beginners, or aren't going to teach you how to actually begin programming. This one is an exception.
Use a decent text editor with syntax highlighting and line numbering. That's all you should need. A big IDE that also does code completion and the like is not necessarily helpful at the learning stage. Don't spend too long choosing one or setting it up. If you don't already have one, just get Notepad++ (if you're on Windows) and be done with it. If you don't like it you can change it once you get more proficient. Or if you've already paid for Microsoft Visual Studio then use that, but don't go out and get it just for the sake of learning a language. Avoid falling into the trap of spending all your time sharpening your tools and no time using them.
The easiest and fastest way to do this? Find a mentor, or a set of mentors. Not necessarily a real-life mentor, they can be offline, although a real-life mentor is more practical.
You can find these people when you participate in local software development communities, e.g., forums, or user group meetings. Frequent these places, both offline and online; the amount of knowledge that you will learn is immense, not to mention the benefit of being able to bounce ideas off of other people.
Code Complete and Pragmatic Programmer are likewise excellent book suggestions above. I suggest you go with Code Complete first, as it tackles on how to make your code sensible and elegant, which you certainly can use immediately.
Goodluck!
We all learn differently, so don't feel handicapped because of the way you've entered the field.
I guess the simplest, easiest thing I can suggest would be to get yourself a PHP book (seeing as that's what you're familiar with right now) and start from there to build up confidence.
In your spare time, just create some very small basic apps to practice without any pressure. Then take on a language like Python, Java or .NET.. depending on what takes your fancy. With a language or two under your belt, then you can take on books like Code Complete, which will cover some of the more esoteric areas of software development.
Good luck, this is a profession where you really never stop learning.
in case you're interested to becoming a better programmer, i must recommend that you read the pragmatic programmer, don't worry, it's not a full text of codes which will make you pull your hair out but useful lessons which can only be distilled from years of programming experience written in an easy to read but still very informative kind of way :)
I'm not at all convinced that the premise of the "Copy & Paste Generation" is any kind of new phenomenon. Only the tools are available to a wider audience now than before.
If you want to really hone your skills, it might be worthwhile to take some classes, either at a local community college or in a self-directed learning environment through the use of some of the many, fine online resources or books
I believe Code Complete is another book along the same lines of the Pragmatic Programmer that has already been recommended.
I have been your situation before, senior year of high school in an internship I "learned" c and shell programming mostly via copy and paste, and later on at various times when I may have been in a similar situation with specific technologies.
My recommendations:
Take a class at your CC. The one you want is the one that is the prerequisite for the advanced programming classes. They probably also offer a "I've never touched a computer before" level class but this one won't be the formal prereq for the follow on classes. This will probably be in Java.
Work your way through one of the better programming books that includes exercises. Kernighan and Ritchie's C Programming Language is a classic. This would be my recommendation because C is similar enough to PHP to be familiar, but different enough that you will be able to keep them separate. I say this even though you will probably never write a single line of production C. Paul Graham's ANSI Common Lisp is also a suitable choice.
If you are really hard core and have the dedication, you can try Structure and Interpretation of Computer Programs, by Abelson and Sussman. This is the book used in the first programming course at UC Berkeley ( http://webcast.berkeley.edu/course_details.php?seriesid=1906978389 ) and at MIT ( http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and-Computer-Science/6-001Spring-2005/CourseHome/ ). This may be too difficult to attempt outside a school environment. It's designed for bright young students with nothing to do but study and with the regular opportunity to get tutoring from grad students. I include it only for completeness.
I would avoid any web programming books. You already know web programming. I get the impression that you are feeling like you are hitting a bit of a wall, and looking at a way around or over that wall, rather than trying to go directly through it.
I would advise against looking into any web oriented book because it will not give you the big picture, it will describe technique only as they apply to web programming. The important things to understand are how a computer actually operates, the difference between the stack and the heap, pointers, the basics of garbage collection, recursion, and it'd probably be helpful to understand at least extension mechanism. I mean, if you understand shared libraries on Unix, or DLLs on Windows, or classpath and jars on Java, or how to create a library in PHP, Ruby, Perl or Python, any one of those will be fine. It's just the concept of loading outside code that's important.
Take a look at The Structure and Interpretation of Computer Programs and see if you think it would help.
Copy and paste programming refers to using the same code several places instead of putting it in a function or class. If all you do is modify existing source code while following a howto guide, what you do is not called programming, just copy and paste.
What you need to do is read a book on programming, whatever you feel your level is. If you feel its copy and paste level, you should start with a beginners book. Forget everything you think you know, read and follow the book. When you've finished you can remember some of the clever code(?) you noticed during your C&P days.
Mastering any skill takes time, but if you keep at it you'll become better. There is nothing inherently different about programming in that sense. Exactly how you learn best, is a highly individual matter, so it's really hard to give any meaningful advice on that. In my experience, combining different types of learning (practical experience, being around other programmers, reading books, formal education etc. etc.) in even-sized doses works better than just pursuing one type of learning (Such as formal education).
You might find these readings interesting, if you don't know them already:
http://www.norvig.com/21-days.html
http://softwarecraftsmanship.oreilly.com/wiki