Learning PHP and MySQL

Friday, August 18, 2006

Creating myapp/index.php

<?php require_once("smarty.php");
$smarty->assign('test',  '123');
$smarty->display('index.tpl');
?>

Posted by krautgrrl on 08/18 at 11:53 AM
Chapter 10 Code • (110) Comments • (894) TrackbacksPermalink

Wednesday, August 09, 2006

Example 03-01 All you need to start with PHP is a simple HTML document

<html>
<
head>
<
title>Hello  World</title>
</
head>
<
body>
<
p>I  sure  wish  I  had  something  to  say.</p>
</
body>
</
html>

Posted by admin on 08/09 at 03:22 PM
Chapter 3 Code • (3) Comments • (1758) TrackbacksPermalink

Example 03-04 The HTML markup produced by the PHP code

<html>
<
head>
<
title>Hello  World</title>
</
head>
<
body>
Hello  world!<br  />Goodbye.<br  />Over  and  out.
</
body>
</
html>

Posted by admin on 08/09 at 03:23 PM
Chapter 3 Code • (26) Comments • (4349) TrackbacksPermalink

Example 03-06 Reassigning a variable

<?php
$age  
=  30;
$age  =  31;
echo  
$age;
?>

Posted by admin on 08/09 at 03:25 PM
Chapter 3 Code • (2) Comments • (204) TrackbacksPermalink

Thursday, August 03, 2006

Example 04-01 Sum of values

<?php
$Margaritaville  
=  3;  //  Three  margaritas
$Sun_Tan_Application  =  2;  //  Two  applications  of  sun  tan
$Fun_in_the_Sun  =  $Margaritaville  +  $Sun_Tan_Application;
echo  
$Fun_in_the_Sun;
?>

Posted by krautgrrl on 08/03 at 08:06 AM
Chapter 4 Code • (0) Comments • (690) TrackbacksPermalink

Example 04-02 Casting a variable

<?php
$test
=1234;
$test_string=(string)$test;
?>

Posted by krautgrrl on 08/03 at 08:08 AM
Chapter 4 Code • (2) Comments • (103) TrackbacksPermalink

Example 04-03 Lefthand expressions

<?php
3  
=  $locations;  //  bad  -  a  value  can  not  be  assign  to  the  literal  3
$a  +  $b  =  $c;  //bad  -  the  expression  on  the  left  isn't  one  variable
$c  =  $a  +  $b;  //OK
$stores  =  "Becker"."  "."Furniture";  //  OK
?>

Posted by krautgrrl on 08/03 at 08:08 AM
Chapter 4 Code • (0) Comments • (29) TrackbacksPermalink

Example 04-04 Order of precedence

2  +  4  -  5    ==  1;
4  -  5  +  2  ==  1;

4  *  5  /  2  ==  10;
5  /  2  *  4  ==  10;

2  +  4  -  5    ==  1;
4  -  5  +  2  ==  1;

4  *  5  /  2  ==  10;
5  /  2  *  4  ==  10;

Posted by krautgrrl on 08/03 at 08:09 AM
Chapter 4 Code • (0) Comments • (74) TrackbacksPermalink

Example 04-05 The multiplication is done last because of the override

<?php
echo  2  *  3  +  4  +  1;
echo  
2  *  (3  +  4  +  1);
?>

Posted by krautgrrl on 08/03 at 08:10 AM
Chapter 4 Code • (0) Comments • (412) TrackbacksPermalink

Example 04-06 Else and if statements

<?php
if  ($username  ==  "Admin"){
  
echo  ('Welcome  to  the  admin  page.');
}
else  {
  
echo  ('Welcome  to  the  user  page.');
}
?>

Posted by krautgrrl on 08/03 at 08:10 AM
Chapter 4 Code • (0) Comments • (102) TrackbacksPermalink

Example 04-07 Checking multiple conditions

<?php
if  ($username  ==  "Admin"){
  
echo  ('Welcome  to  the  admin  page.');
}
elseif  ($username  ==  "Guest"){
  
echo  ('Please  take  a  look  around.');
}
else  {
  
echo  ("Welcome  back,  $username.");
}
?>

Posted by krautgrrl on 08/03 at 08:11 AM
Chapter 4 Code • (0) Comments • (495) TrackbacksPermalink

Example 04-08 Using the ? operator to create a message

<?php
$logged_in  
=  TRUE;
$user  =  "Admin";
$banner  =  ($logged_in==TRUE)?"Welcome  back  $user!":"Please  login.";
echo  
"$banner";
?>

Posted by krautgrrl on 08/03 at 08:12 AM
Chapter 4 Code • (1) Comments • (352) TrackbacksPermalink

Example 04-09 Using if to test for multiple values

<?php
if  ($action  ==  "ADD")  {
  
echo  "Perform  actions  for  adding.";
  echo  
"As  many  statements  as  you  like  can  be  in  each  block.";
}
elseif  ($action  ==  "MODIFY")  {
  
echo  "Perform  actions  for  modifying.";
}
elseif  ($action  ==  "DELETE")  {
  
echo  "Perform  actions  for  deleting.";
}
?>

Posted by krautgrrl on 08/03 at 08:12 AM
Chapter 4 Code • (0) Comments • (1) TrackbacksPermalink

Example 04-10 Using switch to test for multiple values

<?php
switch  ($action)  {
case  "ADD":
  echo  
"Perform  actions  for  adding.";
  echo  
"As  many  statements  as  you  like  can  be  in  each  block.";
  break;
case  
"MODIFY":
  echo  
"Perform  actions  for  modifying.";
  break;
case  
"DELETE":
  echo  
"Perform  actions  for  deleting.";
  break;
}
?>

Posted by krautgrrl on 08/03 at 08:13 AM
Chapter 4 Code • (0) Comments • (286) TrackbacksPermalink

Example 04-11 What happens when there are no break keywords

<?php
$action
=”ASSEMBLE  ORDER”;
switch  (
$action)  {
case  "ASSEMBLE  ORDER":
  echo  
"Perform  actions  for  order  assembly.<br>";
case  
"PACKAGE":
  echo  
"Perform  actions  for  packing.<br>";
case  
"SHIP":
  echo  
"Perform  actions  for  shipping.<br>";
?>

Posted by krautgrrl on 08/03 at 08:13 AM
Chapter 4 Code • (0) Comments • (382) TrackbacksPermalink
Page 1 of 9 pages  1 2 3 >  Last »

Statistics

This page has been viewed 271393 times
Page rendered in 0.3375 seconds
Total Entries: 224
Total Comments: 16
Total Trackbacks: 307338
Most Recent Entry: 09/27/2006 12:39 pm
Most Recent Comment on: 10/26/2007 10:00 am
Total Members: 2
Total Logged in members: 0
Total guests: 10
Total anonymous users: 0
Most Recent Visitor on: 07/30/2010 05:51 am
The most visitors ever was 1103 on 11/20/2007 12:50 pm

Referrers

Powered by ExpressionEngine