Jump to content


Welcome to Tech-101 Free Computer Support

Welcome to Tech-101 Free Computer Support, join us now to get access to all our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, and so, so much more. It's also quick and totally free, so what are you waiting for? Register Now or Sign In.
Guest Message by DevFuse

PHP


  • Please log in to reply
1 reply to this topic

#1 jobeard

jobeard

    Site Admin

  • Administrators
  • 1,782 posts

Posted 27 January 2012 - 08:26 PM

PHP: Hypertext Preprocessor

[TBD:- this entry is a place holder to be completed]
  • Typicall Environment, (ie where / what it is use )
  • PROS: easy to read and learn
  • CONS:
  • (Procedural, OO, Interpretive): Interpretive, but when invoked, the Just In-Time compiler is invoked to imporve perfomand and diagnose all syntax
  • Link to major provider(s) Php.net
  • Documentation: Online HTML version
  • Simple configuration file (annontated?)
  • Sample "Hello World" program
Sample Hello World
  <?php echo '<p>Hello World</p>'; ?>

When your web server is properly configured, you can write HTML like
<html>
 <head>
  <title>PHP Test</title>
 </head>
 <body>
 <?php echo '<p>Hello World</p>'; ?>
 </body>
</html>
and the PHP will be executed inline as the html is being delivered as the response to create
a stream that the browser will see as
<html>
 <head>
  <title>PHP Test</title>
 </head>
 <body>
   <p>Hello World</p>
 </body>
</html>

J. O. Beard; you + tech-101.com => synergism. Secure your system now

#2 jobeard

jobeard

    Site Admin

  • Administrators
  • 1,782 posts

Posted 16 February 2012 - 01:36 PM

An example of a template system in PHP

All formating (of the web page) is omitted, but easily added as CSS controls from another echoContent($filename) inserted in the html head.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

   SYSTEM "http://www.w3.org/TR/xhtml11/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<!--  classic 'use if desired meta data;
	notice "==TEMPLATE==" to remind you to edit
	on a per-page basis
-->
<title>Tech-101.com: ==TEMPLATE==</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="content-style-type" content="text/css" />
<meta http-equiv="content-language" content="en-us" />
<meta name="title" content="==TEMPLATE==" />
<meta name="description" lang="en" content="==TEMPLATE==" />
<meta name="keywords"	content="==TEMPLATE==, , , " />
<meta name="category"	content="general" />
<meta name="robots"	  content="index,follow" />
<meta name="distribution" content="global" />
<meta name="copyright" content="==TEMPLATE==" />
<!-- end meta -->

<!-- user php function to fetch raw html or other php files
	   to be shown on THIS page
-->
<?php
function echoContent($filename) {

  if ($theData = file_get_contents($filename, FALSE)) {
	echo "$theData";
  } else {
	echo '<span class="ERR">Error opening source file :(\n</span>';  # $filename!\n";
  }

}
?>

</head>
<body>
<?php
	<!-- this would include a common HEADER
   		from the parent directory of the site.
   		This might be the look-n-feel CSS or other common presentation
	-->
	echoContent("../siteHeader.html");
	
	<!- this would include a common MENU system for the site
   	   as shown here, as a common 'banner' across
   	   the top of every page.

		  A two column presentation (menus left, body text right)
   	   would only need a change in this template to
   	   implement a table, row, two cells or
   	   a frameset with two frames
	-->
	echoContent("../siteMenus.html");
	
	<!-- every page should have it's own h1
   		using CSS to center h1's would be simple
	-->
	echo "<H1>==TEMPLATE==</H1>";
	
	<!-- now we fetch the body presentation itself
	-->
	echoContent("pageContent.html");
	
	<!-- and a common site footer
   		perhaps, copyright, and site-common links
   		eg:  about_us,  contact_us,  terms_n_conditions
	-->
	echoContent("../siteFooter.html");
	
?>
</body>
</html>

J. O. Beard; you + tech-101.com => synergism. Secure your system now




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users