On Thu, 4 Oct 2001, Samuel W. Heywood wrote: > Questions: Why does this page have a "PHP3" extension? > Is there anything special or different about PHP3 web pages?
php is a programming language. The php code is embedded in web pages, but when served, the code is interpreted, so the page that gets sent out is the result of the php code rather than the code itself. The php3 extension simply tells the server to execute the embedded php3 code as it serves the page. An identical page with an html extension would show the code rather than execute it. Look at the source HTML for this page, http://twovoyagers.com/lotus/yarn_compute.php3 and you'll see these lines: <!-- --------------begin function definitions------------- --> <!-- --------------------end function definitions---------------- --> Kinda strange that there's nothing in between? Well, actually there is. The file, as it sits on the server, really has this code between those lines: <!-- -------------- begin function definitions ------------- --> <? function FigureWeight ($strand_sz, $ply, $yards) { echo '<td align="left">'; if ($ply == 0) { echo 'ZERO plies?'; } else { $size = $strand_sz / $ply; $gm = $yards / ($size * 1.85); $oz = $yards / ($size * 52.5); $lb = $yards / ($size * 840); echo 'You\'ll need<b> ' . substr($gm,0,5) . ' gm, ' . substr($oz,0,5) . ' oz,</b> or<b> ' . substr($lb,0,5) . ' lb</b>'; } } # End function FigureWeight ?> <? function FigureLength ($strand_sz, $ply, $unit, $weight) { echo '<td align="right">'; if ($ply == 0) { echo 'ZERO plies?'; } else { $size = $strand_sz / $ply; } if ($unit == 'gm') { $length = $size * $weight * 1.85; } elseif ($unit == 'oz') { $length = $size * $weight * 52.5; } else { $length = $size * $weight * 840; } if ($ply) { $length = intval($length); echo '<td align="right">You have <b>' . $length . ' yards</b>'; } } #End FigureWeight ?> <!-- -------------------- end function definitions ---------------- --> PHP has the advantages of JavaScript in that the code is easily included in web pages, (without needing to know about cgi-bin directories, ascii ftp uploads, execute permissions, etc.) but also gives the advantage of cgi in that it relies on the server to run the program rather than relying on the browser being JavaScript 1.2 capable or 1.1 capable, or not JS capable at all. The server will run the php program regardless of what browser is used... no matter whether that browser is Arachne, Lynx, or even telnet. ;-) BTW, php also has a nice interface to databases, so dynamic pages based on MySQL, for instance, are fairly easy to set up. See some interesting benchmarks at http://www.linuxdoc.org/HOWTO/PHP-HOWTO-13.html The php home page is at http://www.php.net/ - Steve
