CODEFETCH™
            Examples
Searched for 1 expression(s): php  
PHP API
php_check_syntax search codefetch
Check the PHP syntax of (and execute) the specified file
php_ini_scanned_files search codefetch
Return a list of .ini files parsed from the additional ini dir
php_logo_guid search codefetch
Gets the logo guid
php_sapi_name search codefetch
Returns the type of interface between web server and PHP
php_strip_whitespace search codefetch
Return source with stripped comments and whitespace
Most relevant API matches shown. View All.
Source code below from:
Beginning PHP and MySQL 5: From Novice to Professional, Second Edition (Beginning: from Novice to Professional)
By W. Jason Gilmore
Published 23 January, 2006
Average rating

      Powells     Alibris

1590595521/ch1/validstatements.php (5 lines)
1 <?php
2    $number = "5";               # $number is a string 
3    $sum = 15 + $number;   # Add an integer and string to produce integer 

1590595521/ch10/basename.php (5 lines)
1 <?php
2    $path = "/home/www/data/users.txt"; 
3    $filename = basename($path); // $filename contains "users.txt" 

1590595521/ch10/dirname.php (4 lines)
1 <?php
2    $path = "/home/www/data/users.txt"; 
3    $dirname = dirname($path); // $dirname contains "/home/www/data" 

1590595521/ch10/disk_free_space.php (4 lines)
1 <?php
2      $drive = "/usr"; 
3      echo round((disk_free_space($drive) / 1048576), 2); 

1590595521/ch10/disk_total_space.php (9 lines)
1 <?php
2    $systempartitions = array("/", "/home","/usr", "/www"); 
3    foreach ($systempartitions as $partition) { 
Source code below from:
Foundation PHP for Dreamweaver 8
By David Powers
Published 19 December, 2005
Average rating

      Powells     Alibris

FdnPHPforDW8/examples/ch02/quirkstest.php (24 lines)
1 <?php session_start(); ?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
3 <html xmlns="http://www.w3.org/1999/xhtml"> 

FdnPHPforDW8/examples/ch03/datetest.php (13 lines)
7  
8 <body> 
9 <?php
10 echo date('l, F  jS, Y'); 
11 ?> 

FdnPHPforDW8/examples/ch05/combined.php (18 lines)
6 </head> 
7 <body> 
8 <?php
9 $tweedledee = "'The time has come,' the Walrus said,\n"; 
10 $tweedledee .= "'To talk of many things:\n"; 

FdnPHPforDW8/examples/ch05/concatenated.php (18 lines)
6 </head> 
7 <body> 
8 <?php
9 $tweedledee = "'The time has come,' the Walrus said,\n"; 
10 $tweedledee = $tweedledee."'To talk of many things:\n"; 

FdnPHPforDW8/examples/ch05/quotes.php (15 lines)
7  
8 <body> 
9 <?php
10 $year = date('Y'); 
11 echo 'Single quotes: The year is $year<br />'; 
Source code below from:
PHP Hacks : Tips & Tools For Creating Dynamic Websites (Hacks)
By Jack Herrington
Published 12 December, 2005
Average rating

      Powells     Alibris

phphacks/adredirector/index.php (16 lines)
1 <?php
2 function redir_link( $url, $text ) 
3 { 
4 ?> 
5 <a href="redir.php?url=<?php echo( $url ); ?>"><?php echo( $text ); ?></a>
6 <?php
7 } 
8 ?> 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
10 <body> 11 Here are my articles:<br/><br/> 12 <?php redir_link( 'article1.html', 'Article one' ); ?><br/> 13 <?php redir_link( 'article2.html', 'Article two' ); ?><br/> 14 <?php redir_link( 'article3.html', 'Article three' ); ?><br/> 15 </body> 16 </html>

phphacks/adredirector/redir.php (27 lines)
1 <?php
2 srand(time()); 
3 if ( mt_rand(0,10) < 7 ) 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
12 function redir() 13 { 14 window.location='<?php echo( $_GET['url'] ); ?>'; 15 } 16 function startTimer() 17 { 18 window.setTimeout( "redir();", 2000 ); 19 } 20 </script> 21 </head> 22 <body onload="startTimer()"> 23 Here is my groovy ad. You can continue onto the article 24 <a href="<?php echo( $_GET['url'] ); ?>">here</a>. Or just 25 wait for a couple of seconds. 26 </body>

phphacks/amazon/index.php (121 lines)
1 <?php
2 require_once 'PEAR.php';
3 require_once 'Services/Amazon.php';
4  
5 $devtoken = "0T3VDGN1DDDN1EAA1S02"; 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
11 ?> 12 <table width="100%" cellspacing="0" cellpadding="3" border="0"> 13 <?php 14 foreach( $products as $product ) { 15 ?> 16 <tr> 17 <td valign="top" width="10%" valign="middle" align="center"> 18 <a href="<?php echo($product['url']); ?>" target="_new"><img src="<?php echo($product['imagesmall']); ?>" border="0" /></a> 19 </td> 20 <td valign="top" width="90%"> 21 <div class="title"><a href="<?php echo($product['url']); ?>" target="_new"><?php echo( $product['name'] ); ?></a></div> 22 <div class="author"><?php echo($product['creator']); ?></div> 23 <div class="date">Release Date: <?php echo($product['release']); ?></div> 24 <div class="price">Price: <?php echo($product['price']); ?></div> 25 </td> 26 </tr>

phphacks/awss/index.php (95 lines)
1 <?php $states = array(
2   array( "Alabama",4447100,1963711,52419.02,1675.01,50744,87.6,38.7 ), 
3   array( "Alaska",626932,260978,663267.26,91316,571951.26,1.1,0.5 ), 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
63 <script> 64 var data = [ 65 <?php $first = true; foreach( $states as $state ) { if ( !$first ) echo( "," ); ?> 66 [ "<?php echo($state[0]); ?>", <?php echo($state[1]); ?>, 67 <?php echo($state[2]); ?>, <?php echo($state[3]); ?>, 68 <?php echo($state[4]); ?>, <?php echo($state[5]); ?>, 69 <?php echo($state[6]); ?>, <?php echo($state[7]); ?> ] 70 <?php $first = false; } ?> 71 ]; 72

phphacks/boxes/BOX1TEST.PHP (16 lines)
1 <html> 
2 <head> 
3 <? include( "box1.php" );
4 add_box_styles(); 
5 ?> 
Source code below from:
PHP Phrasebook (Developer's Library)
By Christian Wenz
Published 26 September, 2005
Average rating

      Powells     Alibris

ch01-strings/check.inc.php (26 lines)
1 <?php
2   function checkNotEmpty($s) { 
3     return (trim($s) !== ''); 

ch01-strings/check.php (9 lines)
1 <?php
2   require_once 'check.inc.php';
3   var_dump(checkNotEmpty("  \r\n  ")); 
4   var_dump(checkNotEmpty('.')); 

ch01-strings/checksum.php (19 lines)
1 <?php
2   $pass = (isset($_GET['pass'])) ? $_GET['pass'] : ''; 
3  

ch01-strings/compare.php (6 lines)
1 <?php
2   $a = 'PHP';
3   $b = 'php';
4   echo 'strcmp(): ' . strcmp($a, $b) . '<br />'; 
5   echo 'strcasecmp(): ' . strcasecmp($a, $b); 

ch01-strings/comparelogin.php (14 lines)
1 <?php
2   $user = (isset($_GET['user'])) ? $_GET['user'] : ''; 
3   $pass = (isset($_GET['pass'])) ? $_GET['pass'] : ''; 
Source code below from:
Pro PHP Security (Pro)
By Chris Snyder and Michael Southwell
Published 29 August, 2005
Average rating

      Powells     Alibris

CHAPTER03/backupDatabase.php (60 lines)
1 #!/usr/local/bin/php
2 <?php
3  
4 // configuration 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
11 if ( count( $argv ) < 2 ) { 12 ?> 13 backupDatabase.php 14 Create a backup of one or more MySQL databases. 15

CHAPTER03/pullFrom.php (68 lines)
1 #!/usr/local/bin/php
2 <?php
3  
4 // configuration 
5 $rsync = '/usr/bin/rsync --rsh=ssh -aCvz --delete-after'; 
6 $username = NULL; // default username 
7  
8 // construct usage reminder notice 
9 ob_start(); 
10 ?> 
11 pullFrom.php
12 Fetches (in place) an updated mirror from a remote host. 
13  
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
24 Use . for the current directory. 25 26 <?php 27 $usage = ob_get_contents(); 28 ob_end_clean();

CHAPTER03/resetPermissions.php (95 lines)
1 #!/usr/local/bin/php
2 <?php
3  
4 // (sample) presets 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
11 ob_start(); 12 ?> 13 resetPermissions.php 14 Changes file ownership and permissions in some location according 15 to a preset scheme.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
22 $preset - 23 Ownership / group / permissions scheme, one of the following: 24 <?php 25 foreach( $presets AS $name=>$scheme ) { 26 print $name . '<br />';

CHAPTER06/integrity.php (183 lines)
1 #!/usr/local/bin/php
2 <?php
3  
4   // simple file class to track detailed file metrics including hash and stats 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
17 $contentHash = md5_file( $this->path ); 18 19 // get all file statistics, see http://php.net/stat 20 // slice off numeric indexes, leaving associative only 21 $this->stats = array_slice( stat( $this->path ), 13 );
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
59 integrity of the specified files. 60 If not, a new index is generated and written to std-out. 61 The index is a serialized PHP array, with one entry per file.\r\n\r\n" ); 62 } 63

CHAPTER06/mcrypt.php (127 lines)
1 <?php
2  
3   class mcrypt { 
Source code below from:
Spring Into PHP 5 (Spring Into)
By Steven Holzner
Published 12 April, 2005
Average rating

      Powells     Alibris

ch01/echo.php (25 lines)
10             Echoing some text: 
11         </H1> 
12         <?php
13             echo "Hello from PHP.";
14         ?> 
15         <H1> 
16             Echoing some more text: 
17         </H1> 
18         <?php
19             echo "Hello from PHP again!";
20         ?> 
21         <BR> 
22         <BR> 
23         <IMG SRC="php-power-white.gif">
24     </BODY> 
25 </HTML> 

ch01/phpconstants.php (20 lines)
2     <HEAD> 
3         <TITLE> 
4             Using PHP constants
5         </TITLE> 
6     </HEAD> 
7  
8     <BODY> 
9         <H1> 
10             Using PHP constants
11         </H1> 
12         <?php
13             define ("pi", 3.1415926535); 
14  

ch01/phphere.php (23 lines)
10             Displaying here Documents 
11         </H1> 
12 <?php
13 echo <<<END 
14 This example uses  
15 "here document" syntax to display all  
16 the text until the ending token is reached. 
17 END; 
18 ?> 
19         <BR> 
20         <BR> 
21         <IMG SRC="php-power-white.gif">
22     </BODY> 
23 </HTML> 

ch01/phphtml.php (17 lines)
2     <HEAD> 
3         <TITLE> 
4             Mixing HTML and PHP!
5         </TITLE> 
6     </HEAD> 
7  
8     <BODY> 
9         <H1> 
10             Mixing HTML and PHP!
11         </H1> 
12         <?php
13             phpinfo();
14         ?> 
15         <IMG SRC="php-power-white.gif">
16     </BODY> 
17 </HTML> 

ch01/phpinterpolation.php (26 lines)
10             Interpolating variables 
11         </H1> 
12         <?php
13             echo "Setting number of apples to 1.<BR>"; 
14              
Source code below from:
Foundation PHP 5 for Flash (Foundation)
By David Powers
Published 01 March, 2005
Average rating

      Powells     Alibris

php files/Ch11/checkdate.php (24 lines)
1 <?php
2 if (isset($_POST['theDate'])) { 
3   // split the date into component parts 

php files/Ch11/current_timestamps.php (15 lines)
8 <body> 
9 <table> 
10 <tr><td><strong>mktime(): </strong></td><td><?php echo mktime(); ?></td></tr>
11 <tr><td><strong>gmmktime(): </strong></td><td><?php echo gmmktime(); ?></td></tr>
12 <tr><td><strong>Difference: </strong></td><td><?php echo gmmktime()-mktime(); ?></td></tr>
13 </table> 
14 </body> 

php files/Ch11/date_formats.php (26 lines)
1 <?php
2 // following line for use in Windows 
3 setlocale(LC_TIME, 'frc');  
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
16 <tr> 17 <td><strong>date('l, F jS Y g.i a '):</strong></td> 18 <td><?php echo date('l, F jS Y g.i a'); ?></td> 19 </tr> 20 <tr> 21 <td><strong>strftime('%A, %d %B %Y %H h %M'):</strong></td> 22 <td><?php echo strftime('%A, %d %B %Y %H h %M'); ?></td> 23 </tr> 24 </table>

php files/Ch11/july4.php (13 lines)
7  
8 <body> 
9 <?php $jul4 = mktime(0,0,0,7,4,2005);
10 echo date('l, jS F Y', $jul4); 
11 ?> 

php files/Ch11/strtotime.php (15 lines)
7  
8 <body> 
9 <?php 
10 $xmas = strtotime('25 Dec 2005'); 
11 $twelvedays = strtotime('+ 12 days', $xmas); 
Source code below from:
Beginning PHP5, Apache, and MySQL Web Development (Programmer to Programmer)
By Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz, and Michael K. Glass
Published 04 February, 2005
Average rating

      Powells     Alibris

Appedix A Example Files/ch03ex01.php (20 lines)
1 <html><head><title>My Title</title></head> 
2 <body> 
3 <?php
4 if (isset($_POST[posted])) { 
5    echo "Thanks. Your first name is $_POST[first_name] and your last name is $_POST[last_name]"; 
6 } else { 
7 ?> 
8 <h2>Please fill out this form</h2> 
9 <form method="POST" action="<?php $PHP_SELF ?>">
10 <input type="hidden" name="posted" value="true"> 
11 First Name<input type="text" name="first_name"><br> 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
13 <input type="submit" value="Send Info"> 14 </form> 15 <?php 16 } 17 ?>

Appedix A Example Files/ch04ex01.php (418 lines)
6  
7 <body bgcolor="#FFFFFF"> 
8 <form method="POST" action="ch04ex01.php">
9 <?php
10 if (isset($_POST[pre_qualify])) { 
11  
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
37 <table width="100%" border="0" cellpadding="6"> 38 <tr> 39 <td><b><font face="Arial, Helvetica, sans-serif">Welcome to Beginning PHP5</font></b></td> 40 <td><b><font face="Arial, Helvetica, sans-serif">Chapter 04</font></b></td> 41 <td><b><font face="Arial, Helvetica, sans-serif">Exercise 01</font></b></td>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
173 </tr> 174 </table> 175 <?php 176 break; 177 178 Case "form02"; 179 180 //display the second form 181 182 ?> 183 184 <input type="hidden" name="high_school_chk" value="<?php echo $_POST[high_school_chk]; ?>"> 185 <input type="hidden" name="high_school" value="<?php echo $_POST[high_school]; ?>"> 186 <input type="hidden" name="trade_school_chk" value="<?php echo $_POST[trade_school_chk]; ?>"> 187 <input type="hidden" name="trade_school" value="<?php echo $_POST[trade_school]; ?>"> 188 <input type="hidden" name="bachelors_chk" value="<?php echo $_POST[bachelors_chk]; ?>"> 189 <input type="hidden" name="bachelors" value="<?php echo $_POST[bachelors]; ?>"> 190 <input type="hidden" name="masters_chk" value="<?php echo $_POST[masters_chk]; ?>"> 191 <input type="hidden" name="masters" value="<?php echo $_POST[masters]; ?>"> 192 <input type="hidden" name="doctorate_chk" value="<?php echo $_POST[doctorate_chk]; ?>">

Appedix A Example Files/ch05ex01.php (93 lines)
7 <body bgcolor="#FFFFFF"> 
8  
9 <?php
10  
11 if (isset($_POST[posted])) { 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
41 ?> 42 43 <form method="POST" action="ch05ex01.php"> 44 <input type="hidden" name="posted" value="true"> 45 <table width="100%" border="0" cellpadding="6"> 46 <tr> 47 <td><b><font face="Arial, Helvetica, sans-serif">Welcome to Beginning PHP5</font></b></td> 48 <td><b><font face="Arial, Helvetica, sans-serif">Chapter 05</font></b></td> 49 <td><b><font face="Arial, Helvetica, sans-serif">Exercise 01</font></b></td>

Appedix A Example Files/ch06ex01.php (259 lines)
6  
7 <body bgcolor="#FFFFFF"> 
8 <?php
9  
10 //create the function to write the HTML tags 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
71 72 ?> 73 <form method="POST" action="ch06ex01.php"> 74 <input type="hidden" name="posted01" value="true"> 75 <input type="hidden" name="field_name01" value="<?php echo $field_name01; ?>"> 76 <input type="hidden" name="field_name02" value="<?php echo $field_name02; ?>"> 77 <input type="hidden" name="field_name03" value="<?php echo $field_name03; ?>"> 78 <input type="hidden" name="field_type01" value="<?php echo $field_type01; ?>"> 79 <input type="hidden" name="field_type02" value="<?php echo $field_type02; ?>"> 80 <input type="hidden" name="field_type03" value="<?php echo $field_type03; ?>"> 81 <table width="50%" border="0" cellpadding="6" align="center"> 82 <tr>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
118 </table> 119 </form> 120 <?php 121 122 } else { 123 124 //begin the table of fields 125 $my_form = "<form method='POST' action='ch06ex01.php'><table width='50%' border='1'>"; 126 127 //construct and display the form made by the user
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
158 159 //begin the table of fields 160 $my_form = "<form method='POST' action='ch06ex01.php'><table width='50%' border='1'>"; 161 162 //construct and display the form made by the user

Appedix A Example Files/ch07ex01.php (86 lines)
6  
7 <body bgcolor="#FFFFFF"> 
8 <?php
9  
10 if (isset($_POST[posted])) { 
11  
12    //get the folder to search for 
13    $folder_to_find = $_POST[folder_name]; 
14  
15    //set the default directory 
16    $default_dir = array(realpath("/Inetpub/wwwroot/beginning_php5/appendix_a/"));
17  
18    //create an array to hold any matches 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
50 } 51 ?> 52 <form method="POST" action="ch07ex01.php"> 53 <input type="hidden" name="posted" value="true"> 54 <table width="100%" border="0" cellpadding="6"> 55 <tr> 56 <td><b><font face="Arial, Helvetica, sans-serif">Welcome to Beginning PHP5</font></b></td> 57 <td><b><font face="Arial, Helvetica, sans-serif">Chapter 07</font></b></td> 58 <td><b><font face="Arial, Helvetica, sans-serif">Exercise 01</font></b></td>
Source code below from:
PHP 5 Objects, Patterns, and Practice
By Matt Zandstra
Published 21 December, 2004
Average rating

      Powells     Alibris

final-code/03/listing03.01.php (13 lines)
1 <?php
2 class ShopProduct { 
3     // class body 

final-code/03/listing03.02.php (14 lines)
1 <?php
2     class ShopProduct { 
3         public $title               = "default product"; 

final-code/03/listing03.03.php (18 lines)
1 <?php
2     class ShopProduct { 
3         public $title               = "default product"; 

final-code/03/listing03.04.php (22 lines)
1 <?php
2     class ShopProduct { 
3         public $title               = "default product"; 

final-code/03/listing03.05.php (24 lines)
1 <?php
2     class ShopProduct { 
3         public $title; 
Source code below from:
Professional PHP5 (Programmer to Programmer)
By Edward Lecky-Thompson, Heow Eide-Goodman, Steven D. Nowicki, and Alec Cove
Published 26 November, 2004
Average rating

      Powells     Alibris

ProPHP5CodeSeparations/ch01/class.Cat.php (26 lines)
1 <?php
2  
3   class Cat { 

ProPHP5CodeSeparations/ch01/class.Cheetah.php (11 lines)
1 <?php
2   require_once('class.Cat.php');
3  
4   class Cheetah extends Cat { 

ProPHP5CodeSeparations/ch01/class.Customer.php (23 lines)
1 <?php
2  
3   class Customer { 

ProPHP5CodeSeparations/ch01/class.Demo.php (11 lines)
1 <?php
2  
3   class Demo { 

ProPHP5CodeSeparations/ch01/class.Door.php (31 lines)
1 <?php
2  
3 require_once('interface.Openable.php');
4  
5 class Door implements Openable { 
Source code below from:
PHP 5 Power Programming (Bruce Perens Open Source)
By Andi Gutmans, Stig Bakken, and Derick Rethans
Published 27 October, 2004
Average rating

      Powells     Alibris

06/examples/mysqli_bind1.php (26 lines)
1 <?php
2  
3 $conn = mysqli_connect("localhost", "test", "", "test"); 

06/examples/mysqli_bind2.php (13 lines)
1 <?php
2  
3 $conn = mysqli_connect("localhost", "test", "", "test"); 

06/examples/mysqli_blob1.php (22 lines)
1 <?php
2  
3 $conn = mysqli_connect("localhost", "test", "", "test"); 

06/examples/mysqli_blob2.php (30 lines)
1 <?php
2  
3 $conn = mysqli_connect("localhost", "test", "", "test"); 
4  
5 if (empty($_GET['id'])) { 
6     $result = $conn->query("SELECT id, length(data) FROM files LIMIT 20"); 
7     if ($result->num_rows == 0) { 
8         print "No images!\n"; 
9         print "<a href=\"mysqli_blob1.php\">Click here to add one</a>\n";
10         exit; 
11     } 
12     while ($row = $result->fetch_row()) { 
13         print "<a href=\"$_SERVER[PHP_SELF]?id=$row[0]\">";
14         print "image $row[0] ($row[1] bytes)</a><br />\n"; 
15     } 

06/examples/mysqli_buffered1.php (32 lines)
1 <?php
2  
3 $conn = mysqli_connect("localhost", "test", "", "world"); 
Source code below from:
Setting Up LAMP: Getting Linux, Apache, MySQL, and PHP Working Together
By Eric Rosebrock, Eric Filson, Eric Rosebrock, and Eric Filson
Published 22 July, 2004
Average rating

      Powells     Alibris

book/Chapter 11/database-connection.php (13 lines)
1 <?php
2 // Database Connection Script 
3  

book/Chapter 11/database-insert.php (14 lines)
1 <?php
2 // Data insertion script 
3 include('database-connection.php');
4 for($i = 0; $i <= 50; $i++){ 
5    if($i % 2) { 

book/Chapter 11/database-test.php (10 lines)
1 <?php
2 // Data test script 
3 include('database-connection.php');
4  
5 $sql = mysql_query("SELECT * FROM my_table"); 
Source code below from:
Beginning PHP 5 and MySQL: From Novice to Professional
By W. J. Gilmore
Published 21 June, 2004
Average rating

      Powells     Alibris

chapter10/backticks.php (4 lines)
1 <?php
2    $result = `date`; 
3    echo "<p>The server timestamp is: $result</p>"; 

chapter10/basename.php (5 lines)
1 <?php
2    $path = "/home/www/data/users.txt"; 
3    $filename = basename($path); // $filename contains "users.txt" 

chapter10/dirname.php (4 lines)
1 <?php
2    $path = "/home/www/data/users.txt"; 
3    $dirname = dirname($path); // $dirname contains "/home/www/data" 

chapter10/diskfreespace.php (4 lines)
1 <?php
2    $drive = "/usr"; 
3    echo round((disk_free_space($drive) / 1048576), 2); 

chapter10/disktotalspace.php (8 lines)
1 <?php
2    $systempartitions = array("/", "/home","/usr", "/www"); 
3    foreach ($systempartitions as $partition) { 
Source code below from:
Web Database Applications with PHP & MySQL, 2nd Edition
By Hugh E. Williams and David Lane
Published 16 May, 2004
Average rating

      Powells     Alibris

wda/appf/example.f-9.php (31 lines)
1 <?php
2   require_once "HTML/Template/ITX.php";
3   require "mysql_sessions.inc"; 
4  

wda/apph/example.h-1.php (36 lines)
9 <body> 
10 <pre> 
11 <?php
12    // (1) Open the database connection 
13    $connection = mysql_connect("localhost","fred","shhh"); 

wda/apph/example.h-2.php (36 lines)
9 <body> 
10 <pre> 
11 <?php
12    // (1) Open the database connection 
13    $connection = mysqli_connect("localhost","fred","shhh"); 

wda/ch02/example.2-1.php (16 lines)
9 <body bgcolor="#ffffff"> 
10   <h1> 
11   <?php
12     print "Hello, world"; 
13   ?> 

wda/ch02/example.2-2.php (12 lines)
1 <?php $outputString = "Hello, world"; ?>
2 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
3                       "http://www.w3.org/TR/html401/loose.dtd"> 
4 <html> 
5 <head> 
6   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
7   <title><?php print $outputString; ?></title>
8 </head> 
9 <body bgcolor="#ffffff"> 
10   <h1><?php print $outputString; ?></h1>
11 </body> 
12 </html> 
Source code below from:
PHP 5 Fast & Easy Web Development (Fast & Easy Web Development)
By Julie C. Meloni
Published 11 May, 2004
Average rating

      Powells     Alibris

allinone_form.php (78 lines)
7 <? 
8 $form_block =" 
9 <FORM METHOD=\"POST\" ACTION=\"$_SERVER[PHP_SELF]\">
10  
11 <P><strong>Your Name:</strong><br> 

comments.php (21 lines)
9 <? 
10  
11 // This is a simple PHP comment.
12  
13 /* This is a C-style, multi-line comment.  You can make this as 

constants2.php (9 lines)
4 echo "<br>This is line number ".__LINE__; 
5  
6 echo "<br>I am using ".PHP_VERSION;
7  
8 echo "<br>This test is being run on ".PHP_OS;
9 ?> 

contact_menu_ch18.php (79 lines)
32 //build form block 
33 $form_block ="<h1>Login</h1> 
34 <form method=POST action=\"$_SERVER[PHP_SELF]\">
35  
36 $msg 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
51 <P><strong>Administration</strong> 52 <ul> 53 <li><a href=\"show_addcontact.php\">Add a Contact</a> 54 <li><a href=\"pick_modcontact.php\">Modify a Contact</a> 55 <li><a href=\"pick_delcontact.php\">Delete a Contact</a> 56 </ul> 57 <P><strong>View Records</strong> 58 <ul> 59 <li><a href=\"show_contactsbyname.php\">Show Contacts, Ordered by Name</a> 60 </ul>"; 61

contact_menu_ch22.php (128 lines)
33     <h1>Login</h1> 
34      
35     <form method=POST action=\"$_SERVER[PHP_SELF]\">
36     $msg 
37      
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
81 $contact_bd_month = $contacts_bd['month']; 82 $contact_bd_date = $contacts_bd['date']; 83 $bd_string .= "<li><a href=\"show_contact.php?id=$contact_id\">$contact_fname $contact_lname</a> ($contact_bd_month"."-"."$contact_bd_date)"; 84 } 85
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
95 <td valign=top> 96 <P><strong>Administration</strong><ul> 97 <li><a href=\"show_addcontact.php\">Add a Contact</a> 98 <li><a href=\"pick_modcontact.php\">Modify a Contact</a> 99 <li><a href=\"pick_delcontact.php\">Delete a Contact</a> 100 </ul> 101 <P><strong>View Records</strong> 102 <ul> 103 <li><a href=\"show_contactsbyname.php \">Show Contacts, Ordered by Name</a> 104 </ul> 105 </td>
Source code below from:
Essential PHP Tools: Modules, Extensions, and Accelerators
By David Sklar
Published 15 March, 2004
Average rating

      Powells     Alibris

1590592808-1/Chapter01/ex1.php (25 lines)
1 <?php
2 // Load the DB code 
3 require 'DB.php';
4  
5 // Connect to the database 

1590592808-1/Chapter02/ex01.php (25 lines)
1 // Load the ADODB code 
2 require 'adodb/adodb.inc.php';
3  
4 // Connect to the database 
5 $conn = &ADONewConnection('mysql'); 
6 $conn->connect('localhost','phpgems','phpgems1','phpgems');
7  
8 // Send a SELECT query to the database 

1590592808-1/Chapter02/ex09.php (5 lines)
1 require 'adodb/rsfilter.inc.php';
2 setlocale(LC_MONETARY,'en_US'); 
3 $rs = $conn->Execute('SELECT flavor,calories,price FROM ice_cream'); 

1590592808-1/Chapter02/ex12.php (3 lines)
1 require 'adodb/adodb-errorhandler.inc.php';
2 // ... establish connection to the database ...… 
3 $rs = $conn->execute('SELECT flavor,calories,price FROM cookies'); 

1590592808-1/Chapter02/ex14.php (7 lines)
1 require 'adodb/adodb-errorpear.inc.php';
2 // ... establish a connection to the database ... 
3 $rs = $conn->execute('SELECT flavor,calories,price FROM cookies'); 
Source code below from:
Advanced PHP Programming
By George Schlossnagle
Published 20 February, 2004
Average rating

      Powells     Alibris

ws/10-1.php (28 lines)
1 <?php
2 // 
3 // Chapter 10, pg 246 

ws/10-10.php (45 lines)
1 <?php
2   // 
3   // Chapter 10, pg 269 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
13 catch (Exception $e) { 14 // if I fail, I should go here 15 header("Location: /index.php"); 16 return; 17 }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
41 42 43 <?php 44 /* vim: set ts=2 sts=2 expandtab ai bs=2 : */ 45 ?>

ws/10-13.php (50 lines)
1 <?php
2   // 
3   // Chapter 10, pg. 275 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
14 catch (Exception $e) { 15 // if I fail, I should go here 16 header("Location: /index.php"); 17 return; 18 }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
41 </body> 42 </html> 43 <?php 44 $cache->end(); 45 ?> 46 47 48 <?php 49 /* vim: set ts=2 sts=2 expandtab ai bs=2 : */ 50 ?>

ws/10-14.php (48 lines)
1 <?php
2 // 
3 // Chapter 10. pg 278 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
44 </tr> 45 </table> 46 <?php 47 } 48 ?>

ws/10-2.php (35 lines)
1 <?php
2 // 
3 // Chapter 10, pg 248 
4 // 
5 $file = $_SERVER['PHP_SELF'];
6 $cachefile = "$file.cache"; 
7  
Source code below from:
Learning PHP 5
By David Sklar
Published July, 2004
Average rating

      Powells     Alibris

LearningPHP5Code/AppendixA/example-A-01.php (1 lines)
1 <?php print "PHP enabled"; ?>

LearningPHP5Code/AppendixA/example-A-02.php (6 lines)
1 require 'DB.php';
2 if (class_exists('DB')) { 
3     print "ok"; 

LearningPHP5Code/AppendixA/example-A-03.php (1 lines)
1 <?php phpinfo(); ?>

LearningPHP5Code/AppendixA/example-A-04.php (23 lines)
1 ; How to specify directories on Unix: forward slash for a separator 
2 ; and a colon between the directory names 
3 include_path = ".:/usr/local/lib/php/includes"
4  
5 ; How to specify directories on Windows: backslash for a separator 
6 ; and a semicolon between the directory names 
7 ; Windows: "\path1;\path2" 
8 include_path = ".;c:\php\includes"
9  
10 ; Report all errors but notices and coding standards violations 

LearningPHP5Code/AppendixA/example-A-05.php (23 lines)
1 ; How to specify directories on Unix: forward slash for a separator 
2 ; and a colon between the directory names 
3 php_value include_path ".:/usr/local/lib/php/includes"
4  
5 ; How to specify directories on Windows: backslash for a separator 
6 ; and a semicolon between the directory names 
7 ; Windows: "\path1;\path2" 
8 php_value include_path ".;c:\php\includes"
9  
10 ; Report all errors but notices and coding standards violations 
11 php_value error_reporting "E_ALL & ~E_STRICT"
12  
13 ; Record errors in the error log 
14 php_flag log_errors On
15  
16 ; Don't automatically create variables from form data 
17 php_flag register_globals Off
18  
19 ; An uploaded file can't be more than 2 megabytes 
20 php_value upload_max_filesize 2M
21  
22 ; Sessions expire after 1440 seconds 
23 php_value session.gc_maxlifetime 1440
Source code below from:
Core PHP Programming, Third Edition
By Leon Atkinson and Zeev Suraski
Published 08 August, 2003
Average rating

      Powells     Alibris

corephp/1-10.php (24 lines)
1 <?php
2     $Today = date("l F d, Y"); 
3 ?> 
4 <html> 
5 <head> 
6 <title>Listing 1-10</title> 
7 </head> 
8 <body> 
9 Today's date: 
10 <?php
11     /* 
12     ** print today's date 

corephp/1-11.php (23 lines)
5 <body> 
6 <h1> 
7 <?php
8     /* 
9     ** Get today's day of the week 

corephp/1-12.php (18 lines)
6 <h1>Today's Daily Affirmation</h1> 
7 Repeat three times:<br> 
8 <?php
9     for($count = 1; $count <= 3; $count++) 
10     { 

corephp/1-6.php (8 lines)
4 </head> 
5 <body> 
6 Today's date: <?php print(Date("l F d, Y")); ?>
7 </body> 
8 </html> 

corephp/1-7.php (14 lines)
5 <body> 
6 Today's date: 
7 <?php
8     /* 
9     ** print today's date 
Source code below from:
Usable Shopping Carts
By Jon Stephens, Jody Kerr, and Clifton Evans
Published 07 July, 2003
Average rating

      Powells     Alibris

tunein/html/cart.php (237 lines)
1 <?php
2   require_once "../includes/top.inc"; 
3 ?> 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
10 <td bgcolor="#CCCCCC" align="right"> 11 <!-- SEARCH --> 12 <?php 13 require_once "../includes/search.inc"; 14 ?> 15 </td> 16 </tr> 17 </table> 18 <table width="100%" border="0" cellspacing="0" cellpadding="0"> 19 <tr> 20 <td valign="top" align="left" width="150" bgcolor="#CCCCCC"> 21 <!-- NAVIGATION --> 22 <?php 23 require_once "../includes/navbar.inc"; 24 ?>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
26 <td valign="top"> 27 <!-- CONTENT AREA --> 28 <?php 29 require_once "../includes/change_cart.inc"; 30 if($update_msg != "")
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
74 <th>QUANTITY</th><th>DESCRIPTION</th><th>UNIT PRICE</th><th>AMOUNT</th> 75 </tr> 76 <?php 77 78 // display full cart
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
118 $line++; 119 120 echo "<tr><td class=\"cart\" align=\"right\" nowrap=\"nowrap\"$bgcolor>\n<form action=\"cart.php\" "; 121 echo "method=\"POST\" onsubmit=\"return checkConfirm(this);\">\n"; 122 echo "<input type=\"text\" name=\"quantity\" size=\"2\" value=\"$quantity\" />\n";
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
189 $line++; 190 191 echo "<tr><td class=\"cart\" align=\"right\" nowrap=\"nowrap\"$bgcolor>\n<form action=\"cart.php\" "; 192 echo "method=\"POST\" onsubmit=\"return checkConfirm();\">\n"; 193 echo "<input type=\"text\" name=\"quantity\" class=\"cart\" size=\"2\" value=\"$quantity\" />\n";
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
224 ?> 225 </table> 226 <p align="center"><a href="<?php echo $last_page; ?>"><<<Back To Previous Page</a> 227 | | | <a href="checkout.php">Proceed to Checkout >>> </a></p> 228 </td> 229 <td valign="top" align="right" width="200"> 230 <?php 231 require_once "../includes/short_cart.inc"; 232 ?>

tunein/html/ccform.php (331 lines)
1 <?php
2   if( !isset($HTTP_POST_VARS) 
3       || 
4       ( $HTTP_REFERER != $PHP_SELF && strpos($HTTP_REFERER,"checkout.php") === FALSE )
5     ) 
6   { 
7     die("<p>You appear to have reached this page in error.</p> 
8           <p>Please <a href=\"index.php\">click here</a> to go to our Home Page.</p>");
9   } 
10  
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
24 <head> 25 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 26 <title>TuneIn - <?php echo $title; ?></title> 27 <link rel="stylesheet" href="../styles/tunein.css" type="text/css"> 28 </head>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
40 <td valign="top"> 41 <!-- CONTENT AREA --> 42 <?php 43 44 $err_msg = "<p class=\"error\">There were problems with the following fields:</p>\n<p>";
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
206 207 <h2>Thank You!</h2> 208 <p>You order in the amount of $<?php printf("%.2f",$order_total); ?> has been processed.</p> 209 <p>You will be receiving a confirmation notice via email shortly.</p> 210 <p>Your reference code is <?php echo $s_id; ?> -- please include this in all correspondence concerning this order.</p> 211 212 <?php 213 } 214 else
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
219 <p>All fields are required.</p> 220 221 <form action="<?php echo $PHP_SELF; ?>" method="POST"> 222 <table width="80%" cellpadding="1" cellspacing="0" border="0"> 223 <tr>

tunein/html/checkout.php (435 lines)
1 <?php
2   require_once "../includes/top.inc"; 
3  
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
11 <body> 12 <p>You don't have any items in your cart.</p> 13 <p>Please <a href="cart.php">click here</a> to continue.</p> 14 </body> 15 </html> 16 <?php 17 exit; 18 }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
32 <td colspan="2" valign="top"> 33 <!-- CONTENT AREA --> 34 <?php 35 if( isset($HTTP_POST_VARS["addressing"]) ) 36 {
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
108 <td>&nbsp;</td> 109 <td align="right"> 110 <form action="ccform.php" method="POST"> 111 <input type="hidden" name="ship_type" value="<?php echo $HTTP_POST_VARS["ship_type"]; ?>" /> 112 <input type="hidden" name="order_total" value="<?php echo $HTTP_POST_VARS["order_total"]; ?>" /> 113 <input type="hidden" name="s_id" value="<?php echo $s_id; ?>" /> 114 <p><input type="submit" name="pmt_cc" class="search" value="Credit Card" title="Place credit card order." /></p> 115 </form> 116 </td> 117 <td align="left"> 118 <form action="otherform.php" method="POST"> 119 <input type="hidden" name="ship_type" value="<?php echo $HTTP_POST_VARS["ship_type"]; ?>" /> 120 <input type="hidden" name="order_total" value="<?php echo $HTTP_POST_VARS["order_total"]; ?>" /> 121 <input type="hidden" name="s_id" value="<?php echo $s_id; ?>" /> 122 <p><input type="submit" name="pmt_other" class="search" value="Printable Form" title="View printable order form." /></p>

tunein/html/checkout1.php (219 lines)
1 <?php
2   require_once "../includes/top.inc"; 
3 ?> 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
15 <td colspan="2" valign="top"> 16 <!-- CONTENT AREA --> 17 <?php 18 19 if( isset($HTTP_POST_VARS["shipping"]) )
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
77 $s_total = $s_albums + $s_tickets; 78 ?> 79 <p><b>Shipping Method</b>: You chose <?php echo $ship_name; ?>.</p> 80 <table border="0" cellpadding="2" cellspacing="0" width="95%"> 81 <tr> 82 <th align="left">Item Type</th><th>Quantity</th><th>Shipping per Item</th><th align="right">Shipping Charge</th> 83 </tr> 84 <?php 85 $item_types = array("CDs","Cassettes","Vinyl LPs","Tickets"); 86 $ship_total = 0;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
109 <tr> 110 <td class="cart" colspan="3" align="right">Shipping Total:</td> 111 <td class="cart" align="right">$<?php printf("%.2f",$ship_total); ?></td> 112 </tr> 113 <tr> 114 <td class="cart" colspan="3" align="right">Merchandise Total:</td> 115 <td class="cart" align="right">$<?php printf("%.2f",$s_total); ?></td> 116 </tr> 117 <tr>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
120 <tr> 121 <td class="cart" colspan="3" align="right"><b>Order Total:</b></td> 122 <td class="cart" align="right"><b>$<?php printf("%.2f",$order_total); ?></b></td> 123 </tr> 124 <tr> 125 <td colspan="2" align="center"> 126 <form action="checkout2.php" method="POST"> 127 <p>If everything appears in order, then click here to continue to the address form.</p> 128 <input type="submit" class="search" name="addressing" value="Continue" title="Continue to address form." /> 129 <input type="hidden" name="ship_type" value="<?php echo $ship_type; ?>" /> 130 <input type="hidden" name="order_total" value="<?php echo $order_total; ?>" /> 131 </form> 132 </td> 133 <td colspan="2" align="center"> 134 <form action="<?php echo $PHP_SELF; ?>" method="GET"> 135 <p>If you wish to change the shipping method, click here to go back to the previous screen.</p> 136 <script type="text/javascript">

tunein/html/checkout2.php (292 lines)
1 <?php
2   require_once "../includes/top.inc"; 
3 ?> 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
15 <td colspan="2" valign="top"> 16 <!-- CONTENT AREA --> 17 <?php 18 if( isset($HTTP_POST_VARS["addressing"]) ) 19 {
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
200 </tr> 201 </table> 202 <?php 203 foreach($HTTP_POST_VARS as $field => $value) 204 { 205 echo "<input type=\"hidden\" name=\"$field\" value=\"$value\" />\n"; 206 } 207 } 208 ?> 209 </form> 210 <?php 211 } 212 else
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
215 <h2>Step 2. Address &amp; Contact Information</h2> 216 <p>Required fields are marked with an asterisk *.</p> 217 <form action="<?php echo $PHP_SELF; ?>" method="POST"> 218 <input type="hidden" name="addressing" value="<?php echo $HTTP_POST_VARS["addressing"]; ?>" /> 219 <input type="hidden" name="ship_type" value="<?php echo $HTTP_POST_VARS["ship_type"]; ?>" /> 220 <input type="hidden" name="order_total" value="<?php echo $HTTP_POST_VARS["order_total"]; ?>" /> 221 <table border="0" cellpadding="1"> 222 <tr> 223 <td class="cart"> 224 *First Name: <input type="text" name="First0Name_required_alphabetic" value="<?php if(isset($HTTP_POST_VARS["First0Name_required_alphabetic"]))echo stripslashes($HTTP_POST_VARS["First0Name_required_alphabetic"]); ?>" /> 225 </td> 226 <td class="cart"> 227 *Last Name: <input type="text" name="Last0Name_required_alphabetic" value="<?php if(isset($HTTP_POST_VARS["Last0Name_required_alphabetic"]))echo stripslashes($HTTP_POST_VARS["Last0Name_required_alphabetic"]); ?>" /> 228 </td> 229 </tr>
Source code below from:
PHP MySQL Website Programming: Problem - Design - Solution
By Chris Lea, Mike Buzzard, Dilip Thomas, and Jessey-White Cinis
Published March, 2003
Average rating

      Powells     Alibris

DVD Life/_lib/_base/config.php (54 lines)
1 <?php
2  
3 // File Location: /_lib/_base/config.php
4  
5 /**  
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
17 define("VERSION", "1.0"); // apps version 18 19 /* assign php configuration variables */ 20 ini_set("track_errors", "1"); // error tracking 21 22 /* assign base system constants */ 23 define("SITE_URL", "http://wrox.mediatemple.net"); // base site url 24 define("SITE_DIR", "/"); // base site directory 25 define("BASE_DIR", $_SERVER["DOCUMENT_ROOT"]); // base file directory 26 define("SELF", $_SERVER["PHP_SELF"]); // self file directive 27 define("FILEMAX", 1500000); // file size max 28

DVD Life/_lib/_base/elements.php (226 lines)
1 <?php
2  
3 // File Location: /_lib/_base/elements.php
4  
5 /**  
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
14 */ 15 16 require_once("funcs.php"); 17 18 // write user errors (usage: must be called inside html body)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
69 ?> 70 <br /> 71 <?php if (is_array($aData)) { ?> 72 <table width="608" border="0" cellpadding="0" cellspacing="0"> 73 <tr> 74 <td width="348" colspan="2"><div class="listrow"><strong>Item Name</strong></div></td> 75 <td width="170"><div class="listrow"><strong>Created</strong></div></td> 76 <td width="90"><div class="listrow"><?php if ($iPerm > 2) { ?><strong>Actions</strong><?php } ?></div></td> 77 </tr> 78 <tr> 79 <td class="dotrule" colspan="4"><img src="../../_img/spc.gif" width="1" height="15" alt="" border="0" /></td> 80 </tr> 81 <?php 82 // loop through data and conditionally display functionality and content 83 $i = 0;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
87 ?> 88 <tr> 89 <td width="16" bgcolor="#<?php print $bg ?>"><div class="listrow<?php print $aData[$i]["Status"] ?>"><?php if ($iPerm > 2) { ?><a href="index.php?op=<?php print $aState[$aData[$i]["Status"]] ?>&id=<?php print $aData[$i]["Id"] ?>" onclick="return verify();"><?php } ?><img src="../../_img/icon_status_<?php print $aData[$i]["Status"] ?>.gif" width="16" height="10" alt="" border="0" /><?php if ($iPerm > 2) { ?></a><?php } ?></div></td> 90 <td width="332" bgcolor="#<?php print $bg ?>"><div class="listrow<?php print $aData[$i]["Status"] ?>"><?php print format($aData[$i]["Name"]) ?></div></td> 91 <td width="170" bgcolor="#<?php print $bg ?>"><div class="listrow<?php print $aData[$i]["Status"] ?>"><?php print date("Y-m-d H:i:s", $aData[$i]["Created"]) ?></div></td>

DVD Life/_lib/_base/funcs.php (68 lines)
1 <?php
2  
3 // File Location: /_lib/_base/funcs.php
4  
5 /**  
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
14 */ 15 16 require_once("config.php"); 17 18 // catch system exception

DVD Life/_lib/_base/handlers.php (99 lines)
1 <?php
2  
3 // File Location: /_lib/_base/handlers.php
4  
5 /**  

DVD Life/_lib/_bin/hourly.newsletter.php (29 lines)
1 #!/usr/bin/php
2 <?php
3  
4 /* COPYRIGHT NOTICE 
5 This software is copyright ©2002 Code Is Artô and licensed for use by distribution from Code Is Artô only. 
6 This source code may not be redistibuted without written consent from the above mentioned entity. */ 
7  
8 ini_set("include_path", ini_get("include_path").":/var/www/html/_lib/_base/:/var/www/html/_lib/_classes/:/var/www/html/site/:/var/www/html/core/"); 
9  
10 require_once("class.newsletter.php");
11  
12 $oNewsletter = new newsletter; 
Source code below from:
PHP Graphics Handbook
By Jason E. Sweat, Allan Kent, and Mitja Slenc
Published 25 February, 2003
Average rating

      Powells     Alibris

ch-5,6,7/Ch05/3d/chiseling.php (64 lines)
1 <? 
2  
3 include("3dlib.php");
4  
5 $imagein=imagecreatefrompng("squarecirc.png"); 

ch-5,6,7/Ch05/3d/graph.php (45 lines)
1 <? 
2  
3 include("3dlib.php");
4  
5 $im=imagecreatefrompng("example24.png"); 

ch-5,6,7/Ch05/3d/phongterms.php (86 lines)
7     <br/> 
8     <br/> 
9 <?php
10  
11 include "../shadows/shadow.php";
12 MakeShadowFile("sign.png", "99%", 15, 15, 15, "50%", "sign_shadow.png"); 
13  
14 include("3dlib.php");
15  
16 $imagein=imagecreatefrompng("sign.png"); 

ch-5,6,7/Ch05/3d/smoothing.php (60 lines)
1 <? 
2  
3 include("3dlib.php");
4  
5 $imagein=imagecreatefrompng("smooth.png"); 

ch-5,6,7/Ch05/3d/texture.php (64 lines)
1 <? 
2  
3 include("3dlib.php");
4  
5 // Create text "3D!" and a pill-like thingy 
Source code below from:
Dreamweaver MX: Advanced PHP Web Development
By Glasshaus Author Team
Published January, 2003
Average rating

      Powells     Alibris

Documents and Settings/matthewma/My Documents/phpdwmx/error/errorhandler.php (51 lines)
1 <?php
2 // Tell PHP to use our function named errorHandler, to handle future errors
3 set_error_handler("errorHandler"); 
4 ?> 
5 <?php
6 // This is the error handler function that PHP calls in the event of an error
7 function errorHandler($errorCode, $errorDescription, $filename, $linenumber, $extraVars){ 
8     $email = "webmaster@website.com"; 

Documents and Settings/matthewma/My Documents/phpdwmx/error/pagewitherror.php (5 lines)
1 <?php require_once($DOCUMENT_ROOT . 'errorhandler.php'); ?>
2  
3 <?php
4 trigger_error("This is a test Error Message",E_USER_ERROR); 
5 ?> 

Documents and Settings/matthewma/My Documents/phpdwmx/graphics/buttons.php (46 lines)
1 <html> 
2 <body> 
3 <?php
4  
5 function generateToolbarButton($text, $filename) { 

Documents and Settings/matthewma/My Documents/phpdwmx/graphics/counterimg.php (14 lines)
1 <?php
2  
3   header('Content-Type: image/png'); 

Documents and Settings/matthewma/My Documents/phpdwmx/graphics/gdcounter.php (23 lines)
1 <?php
2  
3 session_start(); 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
17 <body> 18 Hey, you've been to this page 19 <img src="counterimg.php?count=<?php echo $_SESSION['count'] ?>" alt="<?php echo $_SESSION['count'] ?>"> times. 20 Want to see it <a href="<?php echo $_SERVER['PHP_SELF']; ?>">again?</a> 21 </body> 22 </html>
Source code below from:
PHP Bible, 2nd Edition
By Tim Converse and Joyce Park
Published 11 September, 2002
Average rating

      Powells     Alibris

PHPBible_2ndEd/ch01/greeting.php (23 lines)
4 <BODY> 
5 <P>Hello, 
6 <?php
7 // We have now escaped into PHP mode.
8 // Instead of static variables, the next three lines 
9 // could easily be database calls or even cookies; 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
15 // OK, we are going back to HTML now. 16 ?> 17 . We know who you are! Your first name is <?php echo $firstname; ?>.</P> 18 19 <P>You are visiting our site at <?php echo date('Y-m-d H:i:s'); ?></P> 20 21 <P>Here is a link to your account management page: <A HREF="http://www.example.com/accounts/<?php echo "$firstname$lastname"; ?>/"><?php echo $firstname; ?>'s account management page</A></P> 22 </BODY> 23 </HTML>

PHPBible_2ndEd/ch02/techbizbook.php (41 lines)
2 <HEAD> 
3 <TITLE>TechBizBookGuide example from server</TITLE> 
4 <?php include_once("tbbg-style.css"); ?>
5 <?php include_once("javascript.inc"); ?>
6 </HEAD> 
7 <BODY> 
8 <?php
9 include_once("tbbg-navbar.txt"); 
10 $org = $_GET['org']; 
11 ?> 
12 <TD BGCOLOR="#FFFFFF" ALIGN=LEFT VALIGN=TOP WIDTH=83%> 
13    <TABLE CELLPADDING=5 WIDTH=100%><TR><TD ALIGN=LEFT VALIGN=MIDDLE> 
14    <H2>Books about <?php print("$org"); //passed in from URL ?></H2><BR></TD></TR>
15    <TR><TD WIDTH=50% ALIGN=LEFT> 
16    <?php
17    $dbh = mysql_connect('localhost', 'mysqluser') or die("Unable to open database"); 
18    mysql_select_db("techbizbookguide") or die("Unable to access database"); 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
25 <TR><TD ALIGN=LEFT> 26 <TABLE BORDER=1 CELLPADDING=3> 27 <?php 28 $query2 = "SELECT ID, Title, AuthorFirst, AuthorLast FROM bookinfo WHERE OrgName='$org' ORDER BY AuthorLast"; 29 $qresult2 = mysql_query($query2) or die(mysql_error()); 30 while ($titlelist = mysql_fetch_array($qresult2)) { 31 $bookID = $titlelist[0]; 32 $title = $titlelist[1]; 33 $authorfirst = $titlelist[2]; 34 $authorlast = $titlelist[3]; 35 print("<TR><TD><A HREF=\"book.php?bn=$bookID\" class=\"roll\"> $title</A></TD><TD>$authorfirst $authorlast</TD>"); 36 } 37 ?>

PHPBible_2ndEd/ch04/helloworld.php (12 lines)
1 <HTML> 
2 <HEAD> 
3 <TITLE>My first PHP program</TITLE>
4 </HEAD> 
5  
6 <BODY> 
7 <?php
8 print("Hello, cruel world<BR><BR>\n"); 
9 phpinfo();
10 ?> 
11 </BODY> 

PHPBible_2ndEd/ch06/listing6_1.php (32 lines)
1 <?php
2 $type_examples[0] = 123; // an integer 
3 $type_examples[1] = 3.14159; // a double 

PHPBible_2ndEd/ch06/maxint.php (17 lines)
1 <?php
2 function maxint() 
3 { /* quick-and-dirty function for PHP int size --
4      assumes largest integer is of form 2^n - 1 */ 
5   $to_test = 2; 
Source code below from:
Web Database Applications with PHP & MySQL
By Hugh E. Williams and David Lane
Published March, 2002
Average rating

      Powells     Alibris

customer_receipt.php (87 lines)
7 in derived source files. 
8 The citation should list that the code comes from Hugh E. 
9 Williams and David Lane, "Web Database Application with PHP and MySQL"
10 published by O'Reilly & Associates. 
11 This code is under copyright and cannot be included in any other book, 
12 publication, or educational product without permission from O'Reilly & 
13 Associates. 
14 No warranty is attached; we cannot take responsibility for errors or fitness 
15 for use. 
16 */ 
17 ?> 
18 <?php
19   include 'error.inc'; 
20   include 'db.inc'; 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
56 if (!isset($custID)) 57 { 58 echo "Incorrect parameters to customer_receipt.php"; 59 exit; 60 }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
78 </head> 79 <body bgcolor="white"> 80 <?php 81 // Show the customer confirmation 82 show_HTML_receipt($custID, $connection);

example.2-1.php (32 lines)
7 in derived source files. 
8 The citation should list that the code comes from Hugh E. 
9 Williams and David Lane, "Web Database Application with PHP and MySQL"
10 published by O'Reilly & Associates. 
11 This code is under copyright and cannot be included in any other book, 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
25 <body bgcolor="#ffffff"> 26 <h1> 27 <?php 28 echo "Hello, world"; 29 ?>

example.2-2.php (29 lines)
7 in derived source files. 
8 The citation should list that the code comes from Hugh E. 
9 Williams and David Lane, "Web Database Application with PHP and MySQL"
10 published by O'Reilly & Associates. 
11 This code is under copyright and cannot be included in any other book, 
12 publication, or educational product without permission from O'Reilly & 
13 Associates. 
14 No warranty is attached; we cannot take responsibility for errors or fitness 
15 for use. 
16 */ 
17 ?> 
18 <?php $outputString = "Hello, world"; ?>
19 <!DOCTYPE HTML PUBLIC  
20    "-//W3C//DTD HTML 4.0 Transitional//EN" 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
22 <html> 23 <head> 24 <title><?php echo $outputString; ?></title> 25 </head> 26 <body bgcolor="#ffffff"> 27 <h1><?php echo $outputString; ?></h1> 28 </body> 29 </html>

example.2-3.php (52 lines)
7 in derived source files. 
8 The citation should list that the code comes from Hugh E. 
9 Williams and David Lane, "Web Database Application with PHP and MySQL"
10 published by O'Reilly & Associates. 
11 This code is under copyright and cannot be included in any other book, 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
25 <body bgcolor="#ffffff"> 26 <h1>The Times Tables</h1> 27 <?php 28 29 // Go through each table

example.2-4.php (56 lines)
7 in derived source files. 
8 The citation should list that the code comes from Hugh E. 
9 Williams and David Lane, "Web Database Application with PHP and MySQL"
10 published by O'Reilly & Associates. 
11 This code is under copyright and cannot be included in any other book, 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
25 <body bgcolor="#ffffff"> 26 <h2>A two dimensional array</h2> 27 <?php 28 29 // A two dimensional array using integer indexes
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
38 39 <h2>More sophisticated multi-dimensional array</h2> 40 <?php 41 42 // More sophisticated multi-dimensional array
Source code below from:
Programming PHP
By Rasmus Lerdorf and Kevin Tatroe
Published March, 2002
Average rating

      Powells     Alibris

progphp-examples/ch01/1-1.php (8 lines)
4   </head> 
5   <body> 
6     <?php echo 'Hello,world!'?>
7   </body> 
8 </html> 

progphp-examples/ch01/1-2.php (2 lines)
1 <?php phpinfo();?>

progphp-examples/ch01/1-3.php (19 lines)
5 <body> 
6  
7 <?php
8   if (!empty($_POST['name'])) { 
9     echo "Greetings,{$_POST['name']},and welcome."; 
10   } 
11 ?> 
12  
13 <form action="<?php $PHP_SELF;?>" method="post">
14 Enter your name: <input type="text" name="name"/> 
15 <input type="submit"/> 

progphp-examples/ch01/1-4.php (32 lines)
3 <table border=1> 
4 <tr><th>Movie</th><th>Year</th><th>Actor</th></tr> 
5 <?php
6   //connect 
7   require_once('DB.php');
8   $db =DB::connect("mysql://username:password@server/webdb"); 
9   if (DB::iserror($db)) { 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
26 <td><?= $row[2] ?></td> 27 </tr> 28 <?php 29 } 30 ?>

progphp-examples/ch01/1-5.php (30 lines)
1 <?php
2 if (isset($_GET['message'])) { 
3   // load font and image,calculate width of text 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
23 <head><title>Button Form</title></head> 24 <body> 25 <form action="<?= $PHP_SELF ?>" method="GET"> 26 Enter message to appear on button: 27 <input type="text" name="message" /><br />
Source code below from:
PHP Advanced for the World Wide Web Visual QuickPro Guide
By Larry Ullman
Published 15 December, 2001
Average rating

      Powells     Alibris

1/script_01_01.php (80 lines)
6 </head> 
7 <body> 
8 <?php # script_01_01.php
9 define ("W", $w); 
10 function write_data ($v, $k, $fp) {  

1/script_01_02.php (117 lines)
6 </head> 
7 <body> 
8 <?php
9  
10 define ("WEEK", $week); 

1/script_01_03.php (150 lines)
1 <?php # script_01_03.php
2 // ***************************** 
3 // Online Football Picks System 
4  
5 // Developed by: Larry E. Ullman 
6  
7 // Written: August 2001 
8 // Modified: August 14, 2001 
9  
10 // Contact: php@DMCinsights.com
11  
12 // The process_winners.php page handles the pick_winners.php page. It determines how each player did and stores this information in a text file.
13  
14 // ***************************** 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
21 </head> 22 <body> 23 <?php 24 25 // Set the week as a constant.

1/script_01_05.php (52 lines)
6 </head> 
7 <body> 
8 <?php # make_picks_form.php
9  
10 $file = '2001/week' . $week . '.txt'; // Identify the file based upon which week it is. 
11  
12 if ($games = @file ($file)) { // Read the file into an array. 
13  
14     // If it read the file, print the form. 
15     echo '<form action="store_picks.php" method="post">
16 <table border="1" width="80%" cellspacing="4" cellpadding="4" align="center"> 
17     <tr align="center" valign="top"> 

1/script_01_06.php (33 lines)
6 </head> 
7 <body> 
8 <?php # store_picks.php
9 // This page handles the data from the make_picks_form.php script.
10  
11 // Set the week as a constant. 
Source code below from:
Foundation PHP for Flash
By Steve Webster
Published September, 2001
Average rating

      Powells     Alibris

phpforflash/appendix/basket.php (131 lines)
1 <? 
2     // Flash for PHP
3      
4     // Basket class 

phpforflash/chapter1/lvtest.php (9 lines)
1 <? 
2     // lvtest.php
3  
4     // Store message into variable 
5     $Text = "This is the PHP loadvars test! Do you like it???";
6      
7     // Output to Flash movie in name/value pair format 

phpforflash/chapter1/register.php (84 lines)
5 $dbUser = "yourusername"; 
6 $dbPass = "yourpassword"; 
7 $dbName = "phpforflash";
8 $table = "downloadLog"; 
9  

phpforflash/chapter1/register_setup.php (63 lines)
5 $dbUser = ""; 
6 $dbPass = ""; 
7 $dbName = "phpforflash";
8 $table = "downloadLog"; 
9  

phpforflash/chapter10/addpoll.php (69 lines)
7  
8 <? 
9 // addpoll.php
10 // Case Study 1: User Poll - Foundation PHP for Flash
11  
12 // If the form has been submitted... 
13 if ($action == "add") { 
14     // Include config file 
15     include('common.php');
16  
17     // Connect to database 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
40 ?> 41 42 <form action="addpoll.php" METHOD="post"> 43 <table border="1" cellspacing="2" cellpadding="3"> 44 <tr>

Not satisfied? Try this search biased towards software and programming:
Google