I've yet to find a PHP tutorial/ learning site that I can recommend wholeheartedly and without reservation.
All I can suggest is that the first thing you check on a tutorial is which version of PHP it was written for (pass over -anything- less than version 5.2; 5.3+ is preferable). Next, see how, and how often, they use echo:
PHP Code:
<?php
## lots of echos mixed throughout script ##
################## BAD !!! ##################
$name = $_POST['name']; // logic
echo "Hello, $name!<br>"; // output
$colors = array( 'red','blue','yellow' ); // logic
echo "Choose your favorite color:<br>"; // output
echo "<form>"; // output
foreach( $colors as $color ){ // logic
echo "<input type=radio name=color value=$color> $color<br>"; // output in loop!
}
echo "<input type=submit value=Submit>"; // output
echo "</form>"; // output
PHP Code:
<?php
## all logic first, all output last ##
############## GOOD :) ##############
// logic
$name = $_POST['name'];
$colors = array( 'red','blue','yellow' );
$message = "Hello, $name!<br>
Choose your favorite color:<br>
<form>";
foreach( $colors as $color ){
$message .= "<input type=radio name=color value=$color> $color<br>";
}
$message .= "<input type=submit value=Submit>
</form>";
//output
echo $message;
exit;
Obviously, php.net is the authoritative reference site, and is fantastic, at that, but it is a *reference,* not a *tutorial.*
Edit:

Originally Posted by
bernie1227
Like I said before, and as others said, I suggest a full grasp of html + css before starting on scripting languages...
I'd suggest using tizag for php as well, as google don't like php.
except for the fact that they do exactly what I just described, tizag does do a decent job with introductory PHP concepts. Just avoid mixing PHP and HTML
PHP Code:
<?php
## DON'T DO THIS:
php php php
?>
html html html
html <?php php php?>
html
<?php
php
?>html
, and avoid the mysql_* functions (they're outdated; use mysqli_* or PDO instead).
I absolutely agree that you need to be very thoroughly familiar with HTML (as well as CSS, and javascript if you plan to use it) *before* trying to figure out something like PHP. PHP *writes* HTML, so obviously, you need to be able to do your HTML without too much effort so you can concentrate on learning the PHP stuff.
Bookmarks