Building things helps an awful lot.
Mathematically-minded people have a bit of an advantage here, in that we are (relatively) easily amused by things that seem to fall into the category of "so what?" to most people. Misson's arbitrary-precision and rational number classes are good examples of the genus—when you understand that asking the machine to add 9/32 and 3/32 and having it tell you the answer is 3/8 is a Big Deal™, you do a little happy dance and dig deeper. Similarly, building something where 0.3
actually equals 0.1 + 0.2 for a change is cause for celebration (whether you understand that or not).
Finding something to build that will hold your interest as you progress can be a little more difficult if maths aren't a turn-on. If you already know enough of the web front end (HTML, CSS, JS, the DOM and/or jQuery) that you don't need to learn them from scratch as well, then it's relatively easy to mock up a simple CRUD* application (the sort of thing you might actually be trying to learn to build) on an HTML page or two, then slowly turn Pinocchio into a real boy as you learn. Along the way, you'll find that things that you had previously written may have worked, but probably weren't the best way to go about it, so you refactor† according to your now-better understanding of the problem, and optimize‡ where you can.
For a basic intro to programming, I usually recommend starting with lectures 1A to 6B of
Structure and Interpretation of Computer Programs. (Lectures 7A to 10B are more interesting for language development, and they're worth a watch later. DSLs (domain-specific languages) can be fantastic tools, and you can create a language that
compiles to PHP to make custom CRUD development go a lot faster if you want to go into the business.) It's not
directly transferable to PHP+MySQL, it will make you see PHP as
Blub, leave you dissatisfied with your working toolset, and you'll probably find Hal Abelson's lectures a little harder to watch than Gerry Sussman's, but it will give you a good foundation in many of the key points in all programming. You'll understand algorithmic complexity, and the trade-offs of time and space. You'll know
Schlemiel the Painter's Algorithm when you see it—even in PHP—and understand how you might go about fixing that. You'll understand iteration and recursion, abstraction, compound data and object-oriented coding.
But yeah, building things helps. Theoretical carpentry is boring too, but making something with your own hands as you learn keeps making it seem worthwhile even though you're learning.
________
* CRUD stands for the simple Create, Read, Update and Delete interaction with a database. Most CRMs, blogs and "social platforms" are really nothing more than a series of CRUD operations.
† Refactoring is the process of rearranging working code to improve its architecture and/or maintainability. It usually includes paying attention to the
DRY ("don't repeat yourself") principle, and may involve creating (or, less often, decomposing) classes to keep the code and the data it works with closer together.
‡ Very often, the easiest things to understand are a long way from the most efficient way to go about things. The rule is "make it work, then make it right".