gnoan.blogspot.com daily 1 Global Nepal Online Academy Global Nepal Online Acedemy: _PHP googlec4b8e18bfb5e32db.html

GNOA is a Complete Online Education Site.

Showing posts with label _PHP. Show all posts
Showing posts with label _PHP. Show all posts

Friday, April 22, 2016

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

Thursday, April 21, 2016

Three main applications of PHP

Three main applications of PHP
Server - side scripting -This is the most traditional and main target
the field for PHP are need three things to make this work :-

• The PHP parser CGI or server module.
• a web server -needs a connected PHP installation
• The web browser - Access PHP document pages by URL
Command line scripting -You can run a PHP script without
a server or browser. you only would like the PHP parser to use it this
way. These scripts can also be used for simple word processing
tasks similar to Perl
Writing client-side GUI applications -PHP is probably not the very
the best language to write windowing applications, but PHP.
GTK PHP Graphics Tool Kit can be used to write such programs.
Not addressed in this course.

PHP v Perl
Let's compare Perl and PHP first
Perl :
• interpreted language optimized to process text files - Ideal for
CGI usage .
• using a Perl script as a CGI means that once an online form
Calls to process the script will load the web server of the Perl
script and the output pipe of the script to the user, on the
Web browser .
• simple syntax similar to C
• including advanced functionality through a large number of packets
( CPAN )
PHP v Perl ( Cont. )
PHP:
• Server side scripting language implanted in HTML pages .
• Handled by the web server if the HTML page is loaded.
• PHP code included in special HTML tags that decompose by
the Web server.
• Syntax is different from Perl ( but not much else )
• PHP also has some very advanced features.


The advantages of Perl / PHP

Perl has many advantages:
• general purpose language - functions to do almost anything.
• Perl modules that can be downloaded and loaded into a Perl
script.
• Scripts can also be made to be processed by the web server and
by a user of the shell (NOT WEB-BASED ) , if necessary.

The advantages of Perl / PHP ( Cont. )
PHP also has some advantages :
• it is included in HTML pages .
This means that:
- all your work can be done in the same folder , and
- a single file can contain HTML and PHP code
- much easier to edit / maintenance of web pages.
- This improves tasks such
-Dynamic page processing.
- Checking and doing simple HTML form based on tasks.
- database connectivity


Disadvantages of Perl / PHP
• Management of simple scripts is harder than PHP:
- Scripts should be loaded individually from the hypertext markup language pages.
- typically scripts also be stored in a special folder - eg cgi-lib.pl,
scripts, so do not need to load a separate location.
• PHP integrates well into HTML files - • If the PHP code complex can lead to a complex
• highly suitable for simple dynamic web processing,
mixture of code on the page. Disadvantages of Perl / PHP (Cont.) PHP: • Not so great for more complex tasks
* Not as general purpose as Perl.
- harder to parse / understand and maintain much code mixed with web page (see above). * PHP requires that the server is configured to parse PHP files.
they should not be used in files which do not have to be processed.
* Perl similar but both now globaly supported. * also, PHP files must decompose by the server at any load, so * Perl similar but both slightly less overhead. Examples of applications of Perl / PHP
• heavy database Access / Usage
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. PHP: better suited for dynamic html, such • process simple form
E.g. a database-connected simple database connectivity.
• creating a complex site integration

Introduction of PHP

PHP started as a small open source project that evolved as more and more people
found out how useful it was. Rasmus Lerdorf released the first form of PHP way back
in 1994.
1. PHP is a recursive acronym for "PHP: hypertext Preprocessor".
2. PHP is a server-side scripting language that is embedded in HTML. it is used to
manage dynamic content, databases, session tracking, even build entire eCommerce
sites.
3. it is integrated with a number of popular databases, including MySQL, Oracle, Sybase and Microsoft SQL Server.
4. PHP is pleasantly zippy in its execution, especially when collected an  Apache
module on the UNIX.
 The Mysql server once started and executes even very
complex queries with immense result sets in record-setting time.
5. PHP supports a large number of major protocols such as POP3 and  IMAP. PHP4 added support for Java spread object styles making n-tier development a possibility for the first time.
6. PHP is forgiving: PHP is forgiving: PHP language stabs to be as merciful
7. PHP Syntax is C-Like.


PHP Features
The main features of PHP are:
• PHP is web-specific and open source
• Scripts are embedded into static hypertext markup language files
• fast execution of scripts
• fast access to the database tier of applications
• Supported by most web server and OS.
• for IMAP, NNTP, SMTP and POP3. 
• Supports many DBM
• Supports many DBMS libraries available for UNIX system DBM,
MySQL, Oracle,
• Dynamic Output any text, hypertext markup language XHTML and any other XML file.
• also Dynamic Output images, pdf file, and even Flash movies
• Text processing features, from the POSIX Extended or Perl regular expressions
to parsing XML document.
• a fully featured programming language suitable for complex system
development











What can PHP do?
As we have just aforementioned PHP is a fully featured programming language
so it will do just about everything.
However, it is best suited and is mainly focused on server-side
scripting so {you can|you'll|you'll be able to} do anything any other CGI program can do
such as:
• Collect form data,
• Generate dynamic page content,
• Send & receive cookies.
• But PHP can do ample extra than we have not got time to deal with
here
– Please refer to recommended course book.
– websites: http://www.php.org,
http://www.php-scripts.com, http://php.resourceindex.com,
and others.

PHP support and installation.
PHP will be used on all major OS :
• Linux
• many UNIX operating system variants ( including power unit - UX , Solaris, and OpenBSD )
Microsoft Windows ,
• Mac OS X
• Windows
• RISC OS ,
• and probably others.
PHP already installed on the varsity network

Google

100