Examples of applications of Perl / PHP
Examples of applications of Perl / PHP
Nor PHP or Perl the best for all web tasks:• Horses for courses
Perl : heavy CGI calculations , for example,
• Search engines ,
• data processing ,
• heavy Access File etc.
• heavy database Access / Usage
PHP: better suited for dynamic HTML , such
• process simple form
• creating a complex site integration
E.g. connected to a database - easy database connectivity.
Including PHP in a web
There are four ways, including PHP during a web page
<?php echo("Hello world!"); ?>
<script language = "php">
echo("Hello world");
</script>
<? echo("Hello world"); ?>
<% echo("Hello world"); %>
You can also use print instead of echo
• method1 is clear and unambiguous- My preferred method
• method 2 is useful in environments containing mixed scripting
languages in the same HTML file.
• method 3 and 4 depending on the server configuration
What happens when the page loads?
When the script runs:
• The code is executed and
• The tag is replaced by the output ( '' hello world '') in
examples above.
• Extra is exactly where the PHP compared to HTML.
- If you view the source of PHP and HTML pages that you do not see PHP.
• can more than a PHP tag in a single web page.
A simple PHP script Preview
Here is the first full PHP script is embedded in HTML:
• we create a level one header with the PHP output text.
• This file is called hello.php:
<html>
<head>
<title>Hello world!</title>
</head>
<body>
<h1><?php echo("Hello world"); ?></h1>
<h1><?php print("This prints the same thing!"); ?></h1>
</body>
<html>
Basic PHP
Comments
PHP supports three types of reactions:
1. Shell style comments - indicated #This is a comment
2. C ++ style comments - called this is A COMMENT
3. C -style comments - marked / * ALL THIS commented! * /
variables
Variables start with the $ symbol (such as Perl) .
E.g.:
$myInteger = 3;
$myString = "Hello world";
$myFloat = 3.145;
PHP data types
data types are not explicitly defined :
• The variable type is determined by the command.
• several Perl.
• The string can be Clear with single and double quotes.
- Rules for String like as in Perl.
• PHP has a boolean type :
Defined as false
- an integer or a value of 0 or float
- The keyword false
- The empty string '' or string ' ' 0 ''
- an empty array or object
- The NULL value
Defined as real
- All non-zero integer or float value
- The key to true
• standard operators with the standard syntax used variables
0 comments :
Post a Comment