Introduction to PHP Programming
As discussed earlier, PHP is an open-source, server-side scripting language. What I didn’t mention, on purpose, was the fact that it is also an embedded CGI language. This certainly will raise some eyebrows! Now, PHP is an embedded language in the sense that it is enclosed within tags and you can easily switch between PHP and HTML without having to use large amounts of code to output HTML.
آموزش برنامه نویسی PHP بصورت خصوصی – کاربردی و با مثالهای واقعی از سایتهای اینترنتی
برای خرید بسته آموزشی طراحی سایت کافیست به Webdesign.epaybank.ir مراجعه نمایید
بعد از خرید بسته آموزشی طراحی سایت میتوانید بیش از 60 ساعت آموزش فارسی و کاربردی برنامه نویسی و طراحی سایت را مشاهده کنید که توسط مدیر آریاکدرز تدریس شده است و توسط گروه طراحان آریاکدرز نیز پشتیبانی می شود.
Common Gateway Interface (CGI) allows you to write computer programs, which can generate HTML and can dynamically process data from Web pages. Before the advent of CGI, you had no option but to create static HTML pages and to keep updating them. Since PHP is a server-side language, you do not need any special browser plug-in or program to run a PHP-enabled Web page. PHP supports all major Web browsers and provides you with tools to build dynamic Web pages.
PHP might be classified as a CGI; however, it imbibes in itself all the characteristics of a complete programming language, such as loop structures, control structures, repetitive tasks, variables, and conditional statements. I will, of course, be dealing with all these features and much more in later chapters.
The three areas where PHP is used are:
Server-side scripting: PHP is most commonly used as a server-side scripting language. To make PHP work as a server-side scripting language, all you need is a PHP parser, a Web server, and a Web browser. However, the Web server has to have a connected PHP installation.
Building client-side GUI applications: Although this is not a preferred use of PHP, with a very good working knowledge of PHP you can build your own client-side GUI applications. You can use PHP-GTK, an extension of PHP, which provides an object-oriented interface for building client-side GUI applications.
Command-line scripting: Your PHP script can run without any browser or server. In this way, it can be used as a simple and easy-to-use scripting language for tasks such as managing databases and messaging files.
After having read so much about the features of PHP, you must by now be quite eager to actually get started with PHP scripting. Without more ado, you may begin. You’ll use the customary ‘Hello World’ example. (Isn’t the popularity of this example amazing? This single example has been to software developers what ‘Twinkle Twinkle, Little Star’ has been to all children.)
The simplest HTML code that you might be aware of goes like this:
3. <title> Hello World</title>
6. Hello World
It can’t get any simpler than this!
Now see how PHP can be embedded into this HTML code:
3. <title> Hello World</title>
7. echo “Hello, World”;
9. Hello World
Most of the preceding code is quite similar to the first example discussed, except for the piece of code that is written between line numbers 6 and 8. This piece of code is the actual PHP code.
Tip You can also use just <? and ?> to start and end the code.
Hence, the basic PHP code can be written as:
echo “Hello, World”;
This produces the output:
Notice here that instead of writing enormous amounts of code to output HTML, writing only a few PHP commands-just three in the preceding example-does the job.