Boston PHP Message Board › Chapter 01: PHP Percolate! Season 6

Chapter 01: PHP Percolate! Season 6

Gene Babon
babong
Boston, MA
Post #: 2,220
Send an Email Post a Greeting


Welcome to the Chapter 1 discussion area for PHP Percolate! Season 6. Please read the chapter, complete the tutorials and post a link to your completed work. Then, let your fellow percolators know how you are progressing by clicking the Add a reply link.

Return to >> Master Discussion List
Gene Babon
babong
Boston, MA
Post #: 2,221
Send an Email Post a Greeting
Chapter 1 -- Complete.

NOTE: I will be using HTML5, instead of XHTML, as my template. Here is the source code, if you'd like to adopt a similar approach.
Jim Merrikin
user 65331472
Boston, MA
Post #: 3
Send an Email Post a Greeting
Hey Gene,

Are you using UTF-8 encoding on your pages? It seems like UTF-8 is taking over the web over the last few years. I had previously used iso-8859-1 but it seems it is falling out of favor.

Thanks,
Jim
Jim Merrikin
user 65331472
Boston, MA
Post #: 4
Send an Email Post a Greeting
Another question for the group.

I've gotten into the good habit of prefixing my jQuery variables with $ because it let's me distinguish my plain vanilla javascript variables from my jQuery variables. Now that I am diving into the world of PHP and using $ for all variables I am wondering if I am going to be dealing with a bit of a mess. I know I can set the jQuery noConflict flag but wondering what others' thoughts are on this matter.

Cheers!
Jim
Jim Merrikin
user 65331472
Boston, MA
Post #: 5
Send an Email Post a Greeting
One thing I noticed in particular with the newline character is that using \n inside of a double quoted string does not result in what one may expect to be placing content on the next line below the current one. The reason for this seems to be that browsers ignore white space unless using the <pre> tag. Very interesting.

Example 1 (using \n does not result in moving the text down):
<?php
echo "I am going to wrap this line here\n and then again here\n and the sentence will end now.";
?>

Example 2 (using the <pre> tag works but loses other baseline style formats as expected):
<?php
echo "<pre>I am going to wrap this line here\nand then again here\nand the sentence will end now.</pre>";
?>

Example 3 (this works as one would expect):
<?php
echo "I am going to wrap this line here<br />and then again here<br />and the sentence will end now.";
?>

Example 4 (cool string function from PHP that automatically inserts <br /> tag before each \n):
<?php
echo nl2br("I am going to wrap this line here<br />and then again here<br />and the sentence will end now.");
?>
Jim Merrikin
user 65331472
Boston, MA
Post #: 6
Send an Email Post a Greeting
Presumably the "Pursue" section at the end of the chapter is homework? If so, here is my result:

http://www.jmerrikin....­

CODE:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Using echo</title>
<link rel="stylesheet" type="text/css" href="common.css" />
</head>
<body>
<?php
define ("BESTYEAR", "2011");
$favTeam = "Boston Bruins";
$favPlayer = "Zdeno Chara";
$favPlayerSalary = 8500000.00;
$favPlayerNumYears = 5;

echo '<h3>The best year for the <span class="team">' . $favTeam . '</span> was ' . BESTYEAR . '!</h3>';

echo "<p>My friend said, <span class=\"sentence\">\"M­y favorite sports team is the $favTeam and one of my favorite players is $favPlayer.\"</span></p>­";

echo "<p class='callout'>In case you did not know, $favPlayer earns $" . number_format($favPlayerSalary) . " per year and has $favPlayerNumYears years left on his contract. This means he will earn $" .
number_format(($favPlayerSalary * $favPlayerNumYears),0) . " in that amount of time!";
?>
</body>
</html>
Gene Babon
babong
Boston, MA
Post #: 2,223
Send an Email Post a Greeting
@Percolators -- Check out Meta Charset Tag in HTML5 for an overview of HTML5 and UTF-8.
Mike Murphy
SeabrookMLM
Seabrook, NH
Post #: 66
Send an Email Post a Greeting
Thanks for the work, Gene. Here is an attempt at the chapter one exercises and review, featuring FancyBox from our jQuery jAM 3 class. Rather than clog up my overcommitted PC, I use the ISP Hosting24 for MySQL/PHP.
Gene Babon
babong
Boston, MA
Post #: 2,226
Send an Email Post a Greeting
@Mike -- Nice job combining technologies. Love the Review section. Just so that others know, Review is bonus and not required. Very nice work.
George
user 48950042
Brockton, MA
Post #: 2
Send an Email Post a Greeting
Finished CH1 the other night and the review questions, going to attempt and post the pursue section tonight!!
Powered by mvnForum

Our Sponsors

People in this
Meetup are also in:

Log in

Not registered with us yet?

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy