CodePrimer
Search a living directory of web syntax. Pick a problem, copy a working sample, then adapt it.
PHP
Beginner
PHP type casting
How do I cast a value to another type?
HTML
Beginner
div vs span
When do I use div or span?
PHP
Beginner
PHP arithmetic operators
What are PHP math operators?
PHP
Beginner
PHP comparison operators
What is == vs === in PHP?
PHP
Beginner
PHP logical operators
How do I combine conditions?
PHP
Beginner
Combined assignment operators
What does += mean in PHP?
PHP
Intermediate
Local vs global scope
Why can’t my function see an outside variable?
CSS
Beginner
Simple CSS reset start
How do I normalize browser defaults a bit?
PHP
Intermediate
Static variable in a function
How do I keep a value between function calls?
PHP
Beginner
if / elseif / else
How do I branch logic in PHP?
JavaScript
Beginner
JavaScript ternary operator
How do I write a one-line if/else?
PHP
Beginner
Ternary and ??
How do I assign with a short conditional?
JavaScript
Beginner
Classic for loop
How do I loop a fixed number of times?
PHP
Beginner
switch statement
How do I handle many discrete cases?
JavaScript
Beginner
for...of over an array
How do I loop array values cleanly?
PHP
Beginner
while loop
How do I loop while a condition is true?
PHP
Beginner
do...while loop
How do I run a loop at least once?
HTML
Beginner
Internal CSS with style tag
How do I put CSS inside the HTML file?