واپس چلیں   پاکستان کی آواز > IT کی دنیا > کمپیوٹر کی باتیں




?What is PHP

short url
جواب
 
LinkBack موضوع کے اختیارات موضوع کی درجہ بندی ظاہری انداز
پرانا 28-01-09, 11:03 AM   #1
Member
اجنبی
 
وقاص بن حسن's Avatar
 
تاریخ شمولیت: Sep 2007
مقام: Lahore - Pakistan
عمر: 33
مراسلات: 43
کمائي: 447
شکریہ: 20
24 مراسلہ میں 55 بارشکریہ ادا کیا گیا
وقاص بن حسن کو ICQ کے ذریعے پیغام ارسال کریں وقاص بن حسن کو MSN کے ذریعے پیغام ارسال کریں وقاص بن حسن کو Yahoo کے ذریعے پیغام ارسال کریں
Post ?What is PHP

?What is PHP

PHP Made Easy by Dr. Perl
اقتباس:
PHP (recursive acronym for "PHP: Hypertext Preprocessor") is a widely-used Open Source general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.

Simple answer, but what does that mean? An example:

Example: An introductory example

کوڈ:
<html>
   <head>
       <title>Example</title>
   </head>
   <body>

       <?php 
       echo "Hi, I'm a PHP script!"; 
       ?>

   </body>
</html>
The above written quote and example is from PHP's official manual. Let me explain and introduce you with PHP in some more detail.

Most of us spend a few hours on internet to check/send emails, view/post something to a discussion board (like this one), to search for some solutions using search engines, do some orkut or facebook. But a few of us will ever realize that what has made these sites so powerful, intelligent and self-maintaining?

Very simple answer to this question is: Web Application Development Technologies.

Don't get afraid of this heavy words term - it's all about the techniques and how you use 'em. Another simple answer would be the, PHP, ASP (Active Server Pages), JSP(Java Server Pages), CFM (Cold Fusion Markup Language) or PERL (Practical Extraction and Reporting Language). These are most renowned web scripting languages and are widely used to develop (or simply program) a website to register users, allow them to post topics, view topics, chat with friends and etc etc.

In this series (EasyPHP) I will introduce you to the PHP, what it can do and how you can benefit from PHP?

You can use PHP to:

- Print current date and time on your website.
- Print greetings to your visitors based on time, like Good Morning, Good Noon and etc.
- Ask comments about your article.
- Offer subscription to your weekly news letter.
- Register visitors to enjoy member services.
- Enable your website to accept online payments, via Credit Cards, PayPal and etc.
- Keep track of daily visits on your website.
- Collect statistical data from daily visits, to find out that how long a user stayed on your website and which pages were browsed mostly and likewise.
- Administer your website remotely, so that you won't need to create page locally and then to upload - called CMS (Content Management System)
- and a very long list to go...


First things first - I mean before you get more excited, let's prepare an environment where you can practice PHP and can create your website.

All you have to do is to download Apache, MySQL and PHP - just install and configure - and you are good to go!!! Sounds crazy? Don't worry this isn't a big deal, just a matter of few clicks. Simply download XAMPP from SourceForge.net: XAMPP: Downloading ... . This is a windows based installer which will install and configure everything for you. During installation it will ask you a few questions, just proceed with clicks - But take care of only one thing that you need to select option for Apache and MySQL to run as a service - when asked.

Once you have installed xampp, look for the "htdocs" folder under the installation of your xampp location. This is the folder where you will place all of your PHP files. The better idea is to create separate folders for each project (or website).

اقتباس:
Quick Note:
Apache - Web Server
MySQL - Database Server
Say Hello to World

The most popular and common first-code, a developer/programmer tries is "A Hello World" example. Fire up your note pad and write following code in a new file.

کوڈ:
<?
echo "Hello World";
?>
Save the file as "helloWorld.php" under "htdocs" folder. Now fire up your favorite web browser (Firefox, IE, Opera, Safari or etc) and type in the following address (URL) in browser's address bar.

http://localhost/helloWorld.php

This should load your helloWorld.php and should say:

اقتباس:
Hello World
in the browser's web page display area. Waowww... we've got another developer...

Now let's have a closer look into our first PHP code (usually called script).

کوڈ:
<?
...
?>
The <? and ?> are the opening and closing markers (tags) of a PHP script, respectively. As I have mentioned earlier in this article that PHP can be embedded in HTML, so the web server has to understand that which part of the web page will be parsed (handled) by PHP itself. Usually, when we save a file as .php extension, web server automatically hands over the calls to PHP compiler (because web server is configured for handling php files also - don't bother with it, just carry on).

Anyway, the PHP code is enclosed between <? and ?> php tags. Alternatively you can write these tags as following also:

کوڈ:
<?PHP
...
?>
or

کوڈ:
<?php
...
?>
Now, move on,

کوڈ:
<?
echo "Hello World";
?>
"echo" is a PHP's language construct, which is also known as a function, but isn't a true function. However, echo outputs one or more strings (data, numeric, alphabets or alphanumeric). Whatever you provide to echo, in double quotes (") or single quotes (') will be printed-out.

Add some more stuff

کوڈ:
<?
/*
My first program in PHP.
Written by Dr. Perl
*/

// Print the message.
echo "Hello World";
?>
As you see /*, */ and // in above code with a few english sentences - are the "comments" or "remarks". A comment is what you insert in your source code to remember or to explain something about a certain part of code, about a chunk of code or about a single line. These are helpful for you. You can use comments to take notes, that what exactly the code does or what has been changed since last version of this code. However, these comments are ignored by PHP compiler and do not affect the code.

Do some variables

کوڈ:
<?
/*
A simple calculator.
Adds two values and prints the result.
*/

// Define some values
$a = 10;
$b = 10;

// Addition
$c = $a + $b;

// Print out the result
echo $c;
?>
$ symbol is used to define a variable. A variable name can be anything meaningful, should start with $ sign. A variable name itself should start with alphabet and can have numerics after that. The above code defines 3 variables, $a, $b and $c. $a and $b contains values while $c contains the result of $a + $b (after addition). "echo" simply prints out the $c (whatever it contains).

Alternatively, you can write above code as:

کوڈ:
<?
/*
A simple calculator.
Adds two values and prints the result.
*/

// Define some values
$a = 10;
$b = 10;

// Print out the result
echo ($a + $b);
?>
Notice the 3rd variable $c is missing, because I have directly written the calculation part in the echo statement. I have put parenthesis around the $a + $b to make it sure that it should be calculated first then should be printed out (ah! the maths - I don't like really!!). Try it without parenthesis and figure out the results.

Summing Up

So far you have got a basic introduction to PHP, Setting up quick environment and writing basic script. Do some practices, below is a list of few useful links which you should keep in your favorites list and may need anytime for quick references.

www.zend.com - The PHP Company, find manual, tutorials and etc.
www.php.net - Home of PHP, find manual, and php downloads
www.mysql.com - MySQL official website
www.welive.ws - Get free space for your own website, PHP supported

Dr. Perl
drperl@hotmail.com
وقاص بن حسن آف لائن ہے  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
وقاص بن حسن کا شکریہ ادا کیا گیا
عبدالقدوس (28-01-09)
کمائي نے وقاص بن حسن کو اس مراسلے کے لئے دیئے
تاریخ رکن عطیہ کرنے کی وجہ رقم
28-01-09 محمدخلیل for php tut. 50
پرانا 28-01-09, 02:00 PM   #2
Senior Member
 
محمدخلیل's Avatar
 
تاریخ شمولیت: Jun 2007
مقام: جنڈانوالہ کھاریاں پاکستان
عمر: 26
مراسلات: 10,807
کمائي: 46,477
شکریہ: 7,233
5,839 مراسلہ میں 14,844 بارشکریہ ادا کیا گیا
محمدخلیل کو MSN کے ذریعے پیغام ارسال کریں محمدخلیل کو Skype™ کے ذریعے پیغام ارسال کریں
Default جواب: ?What is PHP

بہت شکریہ آپ کا۔۔
لیکن اگر اردو میں لکھیں تو کیا ہی بات ہے
محمدخلیل آف لائن ہے  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
جواب

Tags
apache, cold, comments, common, data, database, download, emails, english, enjoy, environment, favorites, find, firefox, folder, folders, note pad, paypal, php, search, system, Waqas Hasan, web developer, web development, website, welive, world


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
موضوع کے اختیارات
ظاہری انداز Rate This Thread
Rate This Thread:



تمام اوقات پاکستانی معیاری وقت ( +5 GMT) کے لحاظ سے ہیں۔ ابھی وقت ہے 06:47 PM

Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.1
جملہ حقوق نشرو اشاعت ©2000 - 2012,پاکستان کی آواز - پاکستان کے فورمزکی انتظامیہ کے پاس مخفوظ ہیں۔ ہم اردو ترجمے کے لیے جناب زبیرکے مشکور ہیں-
اپنا بلاگ مفت حاصل کریں wordpress.pk
ہم pak.net ڈومین نیم کے لیے جناب فاروق سرور خان کے مشکور ہیں

Template-Modifikationen durch TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
Ad Management plugin by RedTyger