Learning PHP and MySQL

Wednesday, July 19, 2006

Example 03-17 Using strcmp to compare two stings

<?php

$name1  
=  "Bill";
$name2  =  "BILL";

$result  =  strcasecmp($name1,  $name2);

if  (!
$result){
echo  "They  match.";
}

?>

Returns:

They match.

Posted by krautgrrl on 07/19 at 03:49 PM
Chapter 3 Code • (0) Comments • (2) TrackbacksPermalink

Example 03-18 Concatenating strings together

<?php
$my_string  
=  "Hello  Max.  My  name  is:  ";
$newline  =  "<br  />";
echo  
$my_string  .  "Paula"  .  $newline;
echo  
"Hi,  I'm  Max.  Who  are  you?  "  .  $my_string  .  $newline;
echo  
"Hi,  I'm  Max.  Who  are  you?  "  .  $my_string  .  "Paula";
//The  last  line  is  the  same  as  echo  "Hi,  I’m  max.  Who  are  you?  $my_string  Paula";
?>

Posted by krautgrrl on 07/19 at 03:55 PM
Chapter 3 Code • (27) Comments • (4) TrackbacksPermalink

Example 03-19 Combining a string and a number

<?php
$str  
=  "This  is  an  example  of  ".  3  ."  in  the  middle  of  a  string.";
echo  
$str;
?>

Displays:

This is an example of 3 in the middle of a string.

Posted by krautgrrl on 07/19 at 03:55 PM
Chapter 3 Code • (0) Comments • (2) TrackbacksPermalink

Example 03-20 Using a constant in your program

<?php
define
("HELLO",  "Hello  world!");
echo  
HELLO;  //  outputs  "Hello  world."
?>

Outputs:

Hello world!

Posted by krautgrrl on 07/19 at 03:56 PM
Chapter 3 Code • (0) Comments • (45) TrackbacksPermalink

Example 03-22 PHP mathematical function usage

<?php>
$sunny_days=300;
$Margaritaville_sunny_days_ratio=$sunny_days/365;
echo  
$Margaritaville_sunny_days_ratio;
?>

Posted by krautgrrl on 07/19 at 03:57 PM
Chapter 3 Code • (0) Comments • (2) TrackbacksPermalink

Example 03-23 Using autoincrement to add to a variable

<?php
$counter
=1;
$counter++;
echo  
$counter
?>

Produces:

2

Posted by krautgrrl on 07/19 at 03:58 PM
Chapter 3 Code • (1) Comments • (3) TrackbacksPermalink

Example 03-24 Using the autodecrement operator

<?php
$counter
=1;
$counter--;
echo  
$counter
?>

Produces:

0

Posted by krautgrrl on 07/19 at 03:58 PM
Chapter 3 Code • (0) Comments • (1) TrackbacksPermalink

Example 03-25 Using pre- and post-increment

<?php
$test
=1;
echo  
"Preincrement:  ".(++$test);
echo  
"<BR>";
echo  
"Value  afterwords:  ".$test;
echo  
"<BR>";
$test=1;
echo  
"Postincrement:  ".($test++);
echo  
"<BR>";
echo  
"Value  afterwords:  ".$test;
?>

Produces:

Preincrement:  2
Value afterwords:  2
Postincrement:  1
Value afterwords:  2

Posted by krautgrrl on 07/19 at 03:59 PM
Chapter 3 Code • (26) Comments • (2) TrackbacksPermalink

Example 3-21 Echoing the line and file predefined constants for a script called predefined_constants

<?php
echo  "Executing  line  ".    __LINE__  .  "  of  PHP  script  "  .  __FILE__  .  '.';
?>

Returns:

Executing line 2 of PHP script /home/www/html/oreilly/ch3/predefined_constants.php.

Posted by krautgrrl on 07/19 at 03:57 PM
Chapter 3 Code • (0) Comments • (1067) TrackbacksPermalink

Thursday, July 06, 2006

Googling now a verb!

’The Oxford English Dictionary (OED), which bills itself as “The definitive record of the English language,” added the company name as a verb in the latest round of updates, placing Google in such august company as FedEx, TiVo, and Xerox.’

Taken from this article: Googling

Posted by krautgrrl on 07/06 at 09:10 AM
Blogging • (0) Comments • (1) TrackbacksPermalink

PHP Variable

<?php 
$age 
30
?>

Then reassign the value with:

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

You should get the new $age as 31.

Posted by krautgrrl on 07/06 at 02:40 PM
(0) Comments • (669) TrackbacksPermalink
Page 2 of 2 pages  <  1 2

Statistics

This page has been viewed 375219 times
Page rendered in 0.2130 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: 8
Total anonymous users: 0
Most Recent Visitor on: 02/10/2012 09:47 am
The most visitors ever was 1103 on 11/20/2007 12:50 pm

Referrers

Powered by ExpressionEngine