Good news good news!!!!!!!!
no php lessons on Saturday and Sunday....
So njoy ur Sunday and Happy Friendship Day
Have fun!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Saturday, July 31, 2010
Friday, July 30, 2010
PHP Variables
• As u know variables r used 4 storing values like text strings, numbers or arrays and when a variable is declared, it can b used over and over again in the script.
• But how variables r declared in php script???[:o]
• All variables in php start wid $ sign symbol.
e.g. $var_name = value;
• Let us take some php code:
• PHP is a loosely typed language:
o In PHP, a variable does not need to be declared before adding a value to it.
o In the example above, you see that you do not have to tell PHP which data type the variable is.
o PHP automatically converts the variable to the correct data type, depending on its value.[:)]
o In a strongly typed programming language, you have to declare (define) the type and name of the variable before using it.
o In PHP, the variable is declared automatically when you use it.
• Naming Rules for variables:
o A variable name must start with a letter or an underscore "_".
o A variable name can only contain alpha-numeric characters and underscores (a-z, A-Z, 0-9, and _ ).
o A variable name should not contain spaces. If a variable name is more than one word, it should be separated with an underscore ($my_string), or with capitalization ($myString)
• But how variables r declared in php script???[:o]
• All variables in php start wid $ sign symbol.
e.g. $var_name = value;
• Let us take some php code:
• PHP is a loosely typed language:
o In PHP, a variable does not need to be declared before adding a value to it.
o In the example above, you see that you do not have to tell PHP which data type the variable is.
o PHP automatically converts the variable to the correct data type, depending on its value.[:)]
o In a strongly typed programming language, you have to declare (define) the type and name of the variable before using it.
o In PHP, the variable is declared automatically when you use it.
• Naming Rules for variables:
o A variable name must start with a letter or an underscore "_".
o A variable name can only contain alpha-numeric characters and underscores (a-z, A-Z, 0-9, and _ ).
o A variable name should not contain spaces. If a variable name is more than one word, it should be separated with an underscore ($my_string), or with capitalization ($myString)
Thursday, July 29, 2010
PHP Syntax
• PHP syntax is very much similar to language C but the whole code of php is contained within a tag.
• All php codes must be contained within the following:
<?php
?>
Or in shorthand form
<?
?>
But this shorthand tag must be supported by your server and I suggest that standard form should be used i.e. <?php
• As you know that php code is inserted in html code, so if you save your file having html code embedded with php code with extension .php then that becomes your php file. But if you save your file with .html extension then php code will not be interpreted by the server.
• A simple php program having php code embedded in html code:
<html>
<head>
<title>My first php page</title>
</head>
<body>
<?php
echo “Hello World...”;
?>
</body>
</html>
Output:
Hello World...
• After writing this code on a text-editor like notepad, save this file with .php extension(helloworld.php) in www(C:/wamp/www) directory. Now you can run your file on your localhost.
• Let us discuss code:
you all are familiar with html code. New thing is code inside <?php, ?> tags. Echo is a command used for displaying something, you can also use ‘print’ command in place of ‘echo’. What you want to display on screen, write in inverted commas. At the end of each statement there should be a semicolon.
• White space is ignored between php statements.
• All php codes must be contained within the following:
<?php
?>
Or in shorthand form
<?
?>
But this shorthand tag must be supported by your server and I suggest that standard form should be used i.e. <?php
• As you know that php code is inserted in html code, so if you save your file having html code embedded with php code with extension .php then that becomes your php file. But if you save your file with .html extension then php code will not be interpreted by the server.
• A simple php program having php code embedded in html code:
<html>
<head>
<title>My first php page</title>
</head>
<body>
<?php
echo “Hello World...”;
?>
</body>
</html>
Output:
Hello World...
• After writing this code on a text-editor like notepad, save this file with .php extension(helloworld.php) in www(C:/wamp/www) directory. Now you can run your file on your localhost.
• Let us discuss code:
you all are familiar with html code. New thing is code inside <?php, ?> tags. Echo is a command used for displaying something, you can also use ‘print’ command in place of ‘echo’. What you want to display on screen, write in inverted commas. At the end of each statement there should be a semicolon.
• White space is ignored between php statements.
Wednesday, July 28, 2010
PHP Installation
PHP Installation:
For PHP to work, you need a server as PHP is a server-side scripting language. If your server supports PHP you don't need to do anything.
Just create some .php files in your web directory, and the server will parse them for you. Because it is free, most web hosts offer PHP support.
However, if your server does not support PHP, you must install PHP.
Then you have to download PHP, a database and a server.
PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.).
PHP is compatible with almost all servers used today (Apache, IIS, etc.).
Alternative method:
Install WAMP server on your computer.
WAMPs are packages of independently-created programs installed on computers that use a Microsoft Windows operating system.
In WAMP, W stands for windows, A stands for apache server, M stands for mysql, P stands for php, However, for linux users there is LAMP available. L stands for Linux and remain same.
Functionalities of WAMP:
WampServer's functionalities are very complete and easy to use so we won't explain here how to use them.
With a left click on WampServer's icon, you will be able to:
- manage your Apache and MySQL services
- switch online/offline (give access to everyone or only localhost)
- install and switch Apache, MySQL and PHP releases
- manage your servers settings
- access your logs
- access your settings files
- create alias
With a right click :
- change WampServer's menu language
- access this page
How to start WAMP:
When you install WampServer, a "www" directory is created (generally c:\wamp\www). Create a directory inside for your project and put your PHP files in it.
Click on the link "Localhost" in the WampServer menu or open your browser and open the http://localhost address.
Add Apache, MySQL and PHP releases
WampServer allows you to install almost all the existing releases of Apache, PHP and MySQL so you can reproduce exactly the settings of your production server.
Then click on the WampServer menu and activate the release that you want to use.
Wait until the WampServer icon become white again and start to work.
PHP Extensions:
PHP files have file extension of “.php”, “.php3”, “.phtml”.
But mostly .php is used.
Important terms:
Localhost: A server application running on your on computer. It always translates to the loopback IP address 127.0.0.1 in IPv4, or ::1 in IPv6.
Tuesday, July 27, 2010
Introduction to PHP
Nowadays, php is used almost in the design of every website. But what is basically php? How it is used? These are the questions which comes to your mind. So let me solve your problem by providing you lessons on daily basis and you can ask about any type of query which comes to your mind. So let us start with today's lesson : Introduction to php (i.e from where it is originated,whats the use of php etc.).
PHP(recursive acronym for PHP:Hypertext Preprocessor):
PHP(recursive acronym for PHP:Hypertext Preprocessor):
- widely used open source general purpose scripting language.
- originally designed for web development to produce dynamic web-pages.
- For this purpose, php code is embedded to html code and interpreted by a web server with a PHP processor module,which generates web page.
- Creator of PHP: Rasmus Lerdorf
- License: free software created under PHP license.
Important terms:
- Open Source Software: A computer software whose source code and certain other rights are available to users i.e. users can study,change and improve the software. e.g. PHP, Linux: computer Operating System, Apache: a web server, Firefox: a web browser etc.
- Scripting Language: A scripting language is a form of programming language that is usually interpreted rather than compiled.e.g. VBScript, Smalltalk, Ruby etc.
- Dynamic webpage: a kind of web-page which changes with time,user, the user interaction, the context etc. to maintain the page up-to-date.e.g News sites, search sites etc.
- PHP-License: php is absolutely free as free software and incompatible with GNU General Public License.
Subscribe to:
Comments (Atom)