The basics of programming in PHP examples. Personal experience as proof: PHP is the main language on the web. Adding PHP code to the markup and the result of the hypertext preprocessor

From the author: is it necessary to know PHP programming language? If you are going to connect your fate with site building, then you have to. Even if you really don't want to! Why is that? We will try to answer all the common "why" associated with this language in our material.

The solution that holds the internet together

This is how PHP was described by an acquaintance of mine who has been creating Internet resources for over a decade. And he is probably right by 200% (and maybe more).

The very history of occurrence of this language says that he was born to "blind" the current version of the Web, to which we are so accustomed. This is probably why some people still cannot understand its power, even after learning the basics of PHP programming.

Proving the role of PHP in creating the Internet is a thankless thing. Here, as they say, supporters of other server-side languages \u200b\u200bmay start to speak. They say that the "hypertext preprocessor" (as the abbreviation PHP stands for) has already outlived its usefulness. Many of its functions are implemented even in ...

Well, screaming and waving your hands in praise of your programming language, which you specialize in, is easy. But the best clue that PHP is in demand is its prevalence.

The following ranking of programming languages, compiled by TIOBE specialists last summer, tells us that PHP has consistently been in the top for several years. Haven't you started looking for a tutorial in PHP yet? Run soon.

If you are wondering why Java jumped like that, then I will answer: thanks to the Android mobile operating system, applications for which are developed in this language.

Own rake

Back in the early 2000s, I was doing "research" in the field of programming. I tried to find out which "party" of developers should join, study which discipline to devote my life to.

I did not consider PHP as a programming language for beginners in principle. He seemed overly confused. ASP.NET is another matter: a commercial language based on C #. Oh, what castles in the air I was building then! And there were all the prerequisites for this:

The technology was developed by such a "thought giant" like Microsoft.

The presence of specialized software - a powerful editor Visual Studio.

Extensive and well described documentation.

Hope for a "healthy" future.

ASP.NET, unlike PHP, was much easier for me. Visual Studio has automated a large number of server-side scripting operations. For example, thanks to an excellent visual editor, it took only a few minutes to create a web page. By dragging and dropping controls and typing their styles in the editor, it was possible to make a website in less than an hour!

But the PHP programming language from scratch was not immediately given to me. Honestly, I tried to make friends with him (I had to somehow pass the exam). But when studying its basics, he seemed callous and even cold.

In general, I took up ASP.NET. I made my first website. Well, everything seems to work in a development environment. I checked cross-browser compatibility in several popular browsers. I think the time has come and "make war." So to speak, show your "brainchild" to the whole country (at least). This is where the "rake" turned out to be.

My attempts to find hosting with ASP.NET support on RuNet were unsuccessful. There were, of course, several paid sites, but the prices for placing the site on them were clearly not "student".

Somehow I dug up a free hosting option (by the way, sponsored by Microsoft) in Burzhunet. Well he "poklatsal", enjoyed the breadth of his thoughts, and then the matter did not go. And all due to the fact that most of the sites were already made in PHP.

After you decide and understand exactly that you are ready to learn PHP programming language, look for a self-help tutorial for beginners. The main thing is that you understand what the author of the publication wants to convey to his readers. Get ready to fuck off right away good amount for quality literature.

But it's better to use an integrated approach - add a sensible one. This will allow you to hone your skills immediately on practical examples. And my advice to you is to copy-paste the code less! Why, I'll explain now.

When you type the example scripts yourself, you will quickly get used to and remember the features of the PHP syntax. As for literature, choose a tutorial with the basics of PHP programming. And it is desirable that the author post the code of all the examples given on his resource on the Web.

Also, immediately before starting the training, download and install Open Server... This software package includes all the environments you need to write and test your code.

Well, let me take my leave for today. Forgive (if anything) for the excessive visibility of the content of the article, but it is necessary to understand the features of this language (still server-side). I wish you quickly grasp the basics of the PHP programming language and get started with real coding!

This site already has articles about and is given. And now we will talk about what PHP is.

What is PHP and what can you do with it?

This easy introduction to PHP explains the basics of PHP and how you can do it. use to create rich web pages and applications... PHP is a programming language that can be used for writing web applications... A web application can be anything from a simple “contact us” form to a complete blogging system, an online store, or a forum. More .

PHP is a server-side language

PHP is known as server-side programming language... It means that it runs on a web server... Most web programming languages \u200b\u200bare server-side languages, but some, like JavaScript, run client-side, which means they run in a web browser.

Server-side languages \u200b\u200bgive you more flexibility because you can do things that are difficult to do with JavaScript — for example, working with files, databases, or working with images. It must be said that JavaScript has spread very quickly these days.

Server side code execution is more in a safe waythan on the client side, as JavaScript does. Because the JavaScript code is sent to the web browser, it is easy for site visitors to view and edit. Even a single page of the site is possible with ease. The server-side code remains on the web server and is not available to site visitors. PHP is a tool that resides on a web server and runs PHP scripts there.

PHP - open source software

PHP is software with open source code ... This means that anyone can access and run PHP. This helps ensure that PHP will run for a long time. PHP is free to download and use. This is the reason that many hosting providers use PHP extensively. You will find that the vast majority of web hosts support PHP.

PHP is geared towards web application development

While many programming languages \u200b\u200bcan be used to create web applications, PHP is one of the languages \u200b\u200bspecifically designed for use on the Internet. PHP has many useful web features, such as:

  • Reading and processing web forms and cookies
  • Functions for creating and working with graphics
  • Establishing connection with popular databases such as
  • Functions for working with.

You can mix PHP code with HTML code

One of the great features of PHP is that you can include blocks of PHP code in HTML pages.

You can insulate PHP blocks with special characters... When the web server receives information about the page,
all PHP blocks are run by the PHP engine, while other parts of the page are sent "as is" to the browser.

This feature makes it easy to make regular web pages interactive. Great tool for forms with feedback and forms with similar functions.

Using PHP

You can use PHP to write almost any type of web application or script. Common PHP applications include:

After reading the article, you can consolidate your knowledge by going through a short one that is based on the material in this article. Good luck in learning PHP!

© Andrey Kukharchik
Computer newspaper

Introduction

The Internet has long been firmly entrenched in our lives. This bold statement can be proven or refuted many times, but somehow everything changes, and no one will argue with this.

Gone are the days when many users personal computers in order to save disk space, we removed the "Internet Explorer" program from all of us adored operating system, because they just didn't need her. Now even those who do not have access to the Web are trying not to touch this program, since the Internet formats have long since moved to other areas of our computer life. And if a modem has settled in the computer, it is simply impossible to avoid the presence of a browser, since I really want to see at least one eye, but what is there, beyond the telephone line? And when the acquaintance took place, it is no longer so easy to give up the advantages of the network. After a while, you begin to realize that you need to somehow invest yourself and your ideas and manifest yourself on the vast expanses of the Global Network. It has even become prestigious to make your own page, and even if there is little useful in it, and the counter records only your infrequent visits, what has been done can become the beginning of a serious project and change your whole life.

Traveling through the vastness global network Internet, you, of course, more than once paid attention to hyperlinks, which sometimes reach outwardly very large sizes and simply lead to bewilderment by the presence of strange symbols. And of course, everyone paid attention to the forms that they had to fill out and get something in return. But few people think about how it all works and what it all means.

I suggest you plunge into the world of programming. This world is in many ways unlike anything, but it has its own unwritten laws and rules, its pros and cons. The world that opens before us is visible for only one more step, but this step must be mastered, and it will be much easier to go further.

PHP history

You should always start with the simplest, and now I will try to introduce you to programming in the PHP scripting language. PHP (reads pee-pee) was born in the fall of 1994, and its creator, Rasmus Lerdorf, used the language for his own purposes, in order to have an idea of \u200b\u200bthose people who visit his website and get acquainted with his resume.

According to the author, PHP was written literally in a day between business meetings. At first it was just an ordinary-looking CGI shell written in Perl, and it served solely for specific purposes. For reference - CGI (Common Gateway Interface) - a common gateway interface, is a standard that is designed to create HTTP server applications.

This application, called a gateway or CGI program, is launched by the server in real time. The server sends user requests to the CGI program, which processes them and returns the result of its work to the user's screen.

Thus, the visitor receives dynamic information that can change as a result of the influence of various factors. The gateway itself (CGI script) can be written in various programming languages \u200b\u200b- C / C ++, Fortran, Perl, TCL, Unix Schell, Visual Basic, Apple Script and others similar languages... But in the case of PHP, for writing it in the original version, the Perl language was chosen, as the most simple and accessible.

As a result of further exploitation, it turned out that the shell has low performance, and the author was forced to rewrite everything from scratch, but in the C language, which made it possible to increase the speed of PHP. The users of the server where the site with the first version of PHP was located asked for the same tool, and although the author did not expect that someone else would use this language, PHP quickly grew into an independent project, and at the beginning of 1995 the first known to us came out product version. The name of this first package was Personal Home Page Tools. At that time, PHP had more than modest capabilities. He had a basic code analyzer that understood several special commands, as well as various utilities for use on the home page, necessary to build useful things like a guestbook, counter, chat, statistics systems and the like. By mid-1995, the language was thoroughly revised, form processing appeared, functions for working with databases were added, and in this form the second version of the product was released.

PHP today is a powerful cross-platform set of tools that resides on the server and is designed to handle custom code embedded in an HTML page. Thanks to this, it becomes possible to easily create dynamic sites. Files created in this way are stored and processed on the server, and when a visitor requests a document from PHP, the script is processed not by the visitor's browser, such as Java Script, but by the server, and only the results of the work are transmitted to the visitor. This is how a CGI program written in C or Perl works. But unlike CGI, PHP code can be embedded anywhere on an HTML page, which is a major advantage over CGI. And besides, the PHP language itself is very easy to learn and does not require any specific knowledge. For example, I personally had quite enough experience acquired ten years ago in computer science lessons at school, where we studied the BASIC language in the then very fashionable and expensive Yamaha. Despite such a rosy characteristic, PHP has its drawbacks. It is worth noting the rather slow (compared to CGI programs) work of PHP scripts, as well as the complexity of writing large and complex programs... One way or another, PHP remains an interpreted language, which will inevitably lead to performance degradation in the case of very large and complex programs, but for performing simple manipulations on the site, PHP is the best choice... No wonder that by the middle of 2000 PHP was used by more than 2.5 million sites!

PHP features

Like any programming language, PHP has its own syntax. It is very similar to the syntax of C or Perl. Programmers writing in these languages \u200b\u200bwill be able to master PHP in just a few days. But even if you have never programmed before, PHP will be easy on you and provide a base for transitioning to more advanced languages. All commands are logical enough, and the rules are simple. The syntax includes statements separated by semicolons. One of the main mistakes novice programmers make is the lack of a semicolon between statements. Fortunately, errors in PHP are displayed on the screen by default (unlike in CGI, where all errors are written to a log file), and it will not be difficult to find them with some care and experience. Moreover, a smart interpreter will prompt the line number where the error occurred.

For programming in PHP you need any text editorbut for convenience it should provide syntax highlighting and line numbering. I'm using CuteHTML that comes with the nice FTP manager CuteFTP latest versions... The editor is very convenient, without unnecessary unnecessary functions, it is built into context menu, does not require installation and has everything you need for programming. We also need a kit for working with PHP. Typically Apache + PHP is used, although this is not required, any server is suitable, for example Microsoft IIS. But the first option is free and has a lot of support from documentation (including in Russian) and forums where you can find out any question.

Now let's get down to business - let's write our first script. In order for the server to know which of the files contains the PHP code, its extension (file) must be made either phtml, or php3, or php. Strictly speaking, any extension can be assigned, but I recommend that you always use phtml for compatibility reasons. Each command in PHP usually starts with ""(hereinafter without quotes). As you remember, several commands are separated by semicolons. Anywhere in the PHP script you can put a comment, it starts with" / * ", and ends with" * / "If the comment is small and takes only one line, you can put "//" and thus easily comment out any line to its end. As usual, spaces, tabs and line feeds are simply ignored and can be used to improve the readability of PHP code.

Display and variables in PHP

PHP makes it very easy to organize the display of text on the screen. Let's consider an example of a script:

This script can be located anywhere in the HTML document, and by itself it is not useful, as it only displays the phrase "Hello world!" But in this way we get acquainted with one of the most common PHP commands - displaying information on the user's screen. In order to give our script useful functions, let's get acquainted with variables. A variable is characterized by a name, type and value. The name can be anything and include numbers, letters of the English alphabet, and allowed characters (for example, underscore or dash). By type, variables are divided into integers, floating point and symbolic. The value according to the type can be almost anything. For example, the variable a \u003d 5. This tells us that the name of the variable is a, the type is integer, the value is 5. Here are more examples of names and values:

As you can see, all variables in PHP (but not only in it) must begin with a $ character, which allows the interpreter to accurately distinguish them from PHP commands. In the first line of our script, the $ name variable is assigned the value 6, and this variable automatically becomes an integer. By the way, there is no need to describe the type of the variable in advance, as in pascal languages or Visual Basic, but although the type separation is purely conditional, each variable automatically tends to use the correct type according to its value. The second line of code sets the variable $ h12 to 4.89, which is a floating point value. The third and fourth lines of code are assigned to their variable valuesthat are character strings. Anything enclosed in quotes (including numbers) will be interpreted as a character string. If variables are not previously defined, but are used, their value is assumed to be either zero or an empty string, depending on the type.

As in any language, you can perform any arithmetic operations on variables, and this does not require the presence of a special operator, it is enough to specify the variable for the result, the equal sign and list the variables or values \u200b\u200bin natural order with the necessary arithmetic signs. Example:

The result of the script is displaying the number 4. All arithmetic operations and functions, multilevel brackets, logical operations, operations of increasing or decreasing by one, and much more are supported. Besides, it is very simple and natural to organize the comparison if - then - otherwise. To do this, PHP uses the if () () else () construction. There are various syntaxes for this operator, but this one is the main one and the most logical of all. (if) if (condition) (then) (what is in quotes is executed) (otherwise) else (what is in quotes is executed). It is not necessary to put a semicolon after the quotes, as usual between operators. But inside quotes, operators are separated from each other only with semicolons. It is allowed to nest several verification operators one into one. In this case, you need to be very careful about the number of closing quotes, since if even one is missing, the interpreter will generate a code error. Let's look at a simple example:

A true comparison uses two equal signs so that the interpreter can easily distinguish comparison from assignment. The result of the script is 95, because $ a is not equal to $ b, and the command echo $ b. $ A; (there is a dot between the variables, not an arithmetic operation sign) displays the specified variables in a row. Inequality (false) is denoted by! \u003d, All other arithmetic and logical symbols and operators are allowed (for example, or, and,\u003e,<= и т.д.).

PHP has a means of rapidly changing a variable by one in the direction of increasing or decreasing. To do this, you need to specify the name of the variable and after it, without an equal sign, - in a row two pluses or minuses, respectively. For example, $ a ++; - the $ a variable will be incremented by one. Simultaneous assignment of one value to several variables is supported - $ a \u003d $ b \u003d 4 ;. Both variables will be equal to four. Here are some more examples of non-standard arithmetic operations in PHP:

File attachments in PHP

Anyone who has made at least one page on the network has faced the problem of changing certain data on it. Of course, it is not difficult when there are several pages or it is one :-), but if you have made a large site, a small addition (for example, in the menu) in hundreds of files can turn into a real nightmare! PHP solves this problem all at once by allowing you to nest one page into another. This is achieved with the REQUIRE and INCLUDE statements. These operators must be followed by the path to the file attachment in parentheses. For example INCLUDE ("text.phtml"). The difference between these operators is that REQUIRE is replaced by the contents of the specified file and can be used only once, while INCLUDE inserts and executes the contents of the specified file, which allows it to be applied multiple times, for example, in a loop. In any case, when the file is executed, the PHP interpreter (correctly speaking - parser) is in the HTML state, and to include it, the code must be enclosed in the construction... File attachments can only take place inside the server space available to PHP. In other words, you cannot use http: //

Quite often there are sites whose links include special characters - &,?,%. All of this could be the result of PHP's work. The fact is that if you add? Name \u003d value at the end of the link, this value will be available under the same name in the file where the link points. If you need to add multiple names, they can be separated by &. Now we can make a website that will be accessible with just one page. And this page will display all the rest of the information based on the data received from the link. The form of such a link will be something like this: http: //name.ru/index.phtml? Link \u003d 1. The unit at the end of the link is our parameter, which will be substituted in the index.phtml file. For example, like this:

... start of file ... ... end of file ...

Please note that the code we have written takes into account the situation when a visitor, for various reasons, specified an incorrect parameter. In this case, a pre-prepared page with an error message is displayed. If the parameter matches any of the site files, it is embedded in the code of the index.phtml file and executed. Thus, the beginning and the end remain the same, and only the middle changes. And any changes do not seem as scary as they used to. After all, they need to be made only in one file, and this will be reflected on the entire site.

There is another way. Its essence lies in the fact that PHP has access to the so-called server environment variables. One of these variables is the path requested by the visitor relative to the site address. And this path becomes available to us for use. In this case, our links will look like this: http: //name.ru/index.phtml? Patch / name.phtml. The second part of the link - patch / name.phtml - will be available to us if we read the $ QUERY_STRING parameter. For example, like this: $ add \u003d $ QUERY_STRING. Now, let's change our head index.phtml file to make everything work automatically. And if the requested parameter is not specified (correctly speaking, it will be equal to an empty line), to open something, assign the $ add variable the name of the file that should be opened as the main page. Let it be the main.phtml file. Then the code will look like this:

... start of file ... ... end of file ...

As you can see, it's even easier. But I want to warn you right away that this method, although simpler than the first, opens the way to obtaining information about the server where the site is located with such a structure organization. An attacker or just a curious person, in the presence of certain circumstances and knowledge, can learn a lot about your server, and this opens a direct path to hacking. So be careful and don't get yourself into big trouble. You can protect yourself from such problems, but that's a completely different story.

An example of a hit counter on PHP

If you have read everything carefully, you will easily get a start-up capital of knowledge, and it will give you the opportunity to independently learn the PHP language in the future. And at the end I suggest you get acquainted with the script code that will allow you to organize a counter of visits on any of the pages of your site. This counter will not be fully functional, since it has quite a few drawbacks, but it is quite suitable as an example of PHP application. Anywhere on your page (but only where it is needed) paste the following code:

Page visitors -

In the same directory as your page, create a counter.dat file, upload it to the server and use your FTP manager to change the attributes of this file so that it is writable. Usually you need to check the boxes on all the attributes of the file. If you don't, the script will continually give an error when trying to write to a file. By the way, in order to prevent this from happening, it is worth putting the @ symbol in front of the command to write and open the file, it will cancel the display of the error message on the visitor's screen. When the attributes are changed, refresh your page on the server and refer to it at its address in the browser. You will see that where you inserted the PHP code, a line appears: "Page visitors -" and then a number corresponding to the number of visits. And no trace of code! It was processed on a server on the Internet, and the result of this execution was simply transmitted to the browser.

The algorithm for this script is very simple. In the first line, we assign the selected variable the name of the file where the number of visits will be stored. In the second, we open a connection to this file for reading. Then we check the success of the connection, and if the file exists and it is readable, we read a string of 10 bytes from it, which is more than enough for the counter, and close the connection to the file. We increase the counter reading by one and display its new value on the screen. At the next stage, we need to write a new counter value, and for this we reopen the connection (descriptor) to the file, but this time for writing, clearing the file contents. If it is successful, write the new counter value there and close the file descriptor. That's all.

At this point, we will consider our first acquaintance with the PHP language complete. Of course, there is still a lot of useful and interesting things left, but, unfortunately, it is impossible to cover everything at once. However, that's why smart people came up with the Network, to make the inaccessible available. There are many useful resources on the Internet on the topic of PHP, and with minimal search engine skills, you can easily find them. And I would advise you to subscribe to the PHP mailing list for everyone !, in which new articles, example scripts appear regularly once a week, there is a section of questions and answers, as well as a lot of other useful information. You can find a subscription form and subscribe at a web address.

All previous issues of the mailing list are also posted there. And at the address you can see how it all works in action. Everything that you find on this site is made on PHP. Chat, forum, private announcements, statistics system - this is only a small part of the possibilities that PHP programming gives us.

PHP programming language

PHP was invented by Rasmus Lerdorf at the end of 1994. The first version was released in 1995 under the name "Personal Home Pages Toolkit", then it was redesigned and called PHP / FI Version 2 (FI - data processing module for forms). Support for mSQL databases has also been added. From that moment on, volunteers began to take part in the development.

PHP usage statistics are approximate, but according to a study by Netcraft, in early 2001, PHP was used on more than 5,300,000 sites worldwide. For comparison: at this time the number of IIS servers was about the same (5 million). The development of the PHP interpreter has taken the form of an organized command process, with the kernel being developed by Zend.com. At the same time, PHP is distributed freely: its latest version can be downloaded from the PHP.net website. PHP modules are shipped with the Apache server, in kits of Linux systems.

Initially, PHP stands for Preprocessor of Home Pages - home page preprocessor. It is the language of scripts embedded in HTML pages and executed on the server. For the most part, its syntax is borrowed from languages \u200b\u200bsuch as C, Perl, Java, and at the same time it adds a lot of features that these languages \u200b\u200black. Simply put, PHP's syntax is a reasonable alternative to both the strictness of C and the "infinity" of Perl.

PHP is endowed with almost a complete set of functionality that a web programmer could only dream of (before the advent of PHP). Its purpose is to enable the creation of dynamically generated web pages as quickly as possible. With good reason, we can say that learning and using PHP will be beneficial to both beginners and professional programmers.

Comparison of the programming language PHP with other programming languages \u200b\u200bfor Web applications

To answer the rationale for the choice of programming tools, PHP was compared with other programming languages \u200b\u200bfor Web applications. PHP's main competitors are JSP (Java Server Pages and Java Scriptlets), ASP.NET (Active Server Pages), Perl, Cold Fusion Server Pages technologies.

1. Programming languages \u200b\u200bPHP and Perl

The Perl language was created by the programmer Larry Wall and stands for Practical Extraction and Report Language. It can be translated as "a language for practical data extraction and reporting." Perl is an interpreter and has been around much earlier than the Web. With the advent of the Internet, Perl has proven to be a convenient tool for creating dynamic Web pages. Perl gained widespread acceptance because it was available on every web server, since almost all of them ran under UNIX, and the only alternative was the more complex C language. Perl loses to PHP in finesse, while PHP offers functionality similar to Perl when much less redundancy and comparative simplicity of syntax. The redundancy of Perl is due to the fact that it was developed for a wide variety of applications, which could not but affect its syntax, while PHP was originally developed for the Internet. In the opinion of many users who did not initially know PHP or Perl, learning PHP is much easier.

2. Programming languages \u200b\u200bPHP and Java

Generally speaking, there is a distinction between Java and Java technology. The Java language is a C-like language that was developed as an "enhanced C ++". Java technology includes client and server parts, as well as access to databases, therefore it is most correct to compare Java technology with the Apache / PHP / MySQL bundle. Java technology was developed as a cross-platform technology for building enterprise-scale Web applications. The main advantages of this technology are cross-platform portability and an object-oriented language, which allows you to create complex and large applications. Disadvantages include slow execution, large memory consumption (fees for cross-platform portability), and the complexity of developing Web applications compared to PHP. Meanwhile, PHP is almost as good as Java in the flexibility and scalability of the created applications. In addition, using Java to develop fairly simple applications is hardly justifiable, and when working on serious tasks, Java is more expensive.

3. Programming languages \u200b\u200bPHP and ASP.NET

ASP (Active Server Pages) is a scripting language from Microsoft. If the ASP language was significantly inferior to PHP in many respects, first of all, in terms of script execution time, then with the advent of ASP.NET technology, the situation has changed. The main strength of ASP.NET is that you can use the full power of the Windows interface to develop Web applications. This allows you to develop pages with a complex interface without worrying about storing, encrypting, and passing variables used in dynamic pages. ASP.NET is tightly integrated with Microsoft's new NET technology. The main feature of developing Web applications using ASP.NET is the ability to use any programming language of the NET runtime. It can be either a modified version of Visual Basic - Visual Basic.NET, or a new C # language or a Java clone - J #. Moreover, several programming languages \u200b\u200bcan be used within a single Web application. All this makes it possible to combine programmers who know different programming languages \u200b\u200bwithin a single project. ASP.NET Web application code is compiled into the Microsoft Intermediate Language (MSIL), sometimes simply called IL. The device-independent IL code is cached in the Web server to improve performance, similar to Java bytecode. But unlike Java technology, which provides platform independence, NET provides development language independence. Running ASP.NET Web applications on non-Windows servers is nearly impossible. Moreover, if a Web application makes heavy use of NET components, viewing a dynamic page will only be possible on Windows and only using Internet Explorer. Therefore, in terms of portability, PHP certainly differs from ASP.NET for the better. Another extremely important argument in favor of PHP is the quick fix of the errors found. Theoretically, you can correct them yourself if you have sufficient qualifications. You can also write a letter to the developers, and with a high degree of probability, the error will be fixed in the next version. And PHP versions come out very often. Another benefit of PHP, especially for beginners, is that it is easier to use to build Web applications. Thus, when choosing between ASP.NET and PHP, you should start with the task at hand. If most of the servers and client machines on the Intranet of a large corporation are running Windows, ASP. NET is more than justified. At the same time, PHP is more useful for developing a Web site on the Internet.

4. Programming languages \u200b\u200bPHP and ColdFusion

The ColdFusion package was developed by Allaire and is intended for the rapid development of both interactive and dynamic Web-documents by processing information obtained from a database. The downside of ColdFusion is its rather low portability. PHP runs on almost all platforms, while ColdFusion only runs on four: Win32, Solaris, HP / UX, and Linux. In addition, ColdFusion, like ASP, is a commercial development. ColdFusion is not widely used. Compared to PHP, it is more resource intensive. The advantage of ColdFusion is a good integrated development environment and, as a result, simpler language constructs than in PHP and faster code writing. True, due to such a high-level language, some tasks are more difficult to solve in it.

5. Programming languages \u200b\u200bPHP 4.0 and PHP 5.0

The main differences lie in the implementation of the object-oriented model. PHP 4.0 was powered by Zend Engine 1.0. For the release of PHP 5.0, Zend completely rewrote the engine and released Zend Engine 2.0, which, according to the creators, implements a "new object model". Compared to PHP 4.0, the fifth version of the language has the following features:

1. Introduced private and public (protected) members and methods of the class, as well as abstract classes and methods.

2. Introduced interfaces, while the class can implement an arbitrary list of interfaces.

3. PHP 5 also has advanced features for cloning objects. The designed copy constructor allows you not only to clone objects identically, but to change some of their properties.

4. Introduced constant members and class methods.

5. One of the most important innovations is the presence of destructors.

6. The good news is that PHP 5.0 introduces static class members. In PHP 4.0, if there was a need to use static members, it was necessary to use an artificial trick, which consisted in combining global variables with static methods. This resulted in classes that acted in the same way as static ones. This technique, to put it mildly, is not very good, since it caused problems associated with the use of global variables. Now in PHP 5.0, static methods can be declared explicitly using the static keyword.

7. PHP 5.0 introduces an exception handling mechanism that is not available in PHP 4.0. Thus, as a result of such innovations in the object model, PHP 5.0 has become a fully professional programming language, which allows it to be used to solve problems of any complexity.

While we are learning to create websites, we often come across the term PHP, but not everyone knows exactly what it is and very few people bother to understand and study this topic in detail. What is php programming? And what is it for? A frequent question for newbies, now I'll tell you everything!

Indeed, sometimes there is simply no need for it. For example, to create, it is not at all necessary to deeply know PHP, usually knowledge of HTML and CSS is quite enough, sometimes you need to change something in PHP code, but usually the "copy-paste" method is enough.

Nevertheless, knowledge of PHP is never superfluous for a layout designer to understand the code of others, and for a webmaster it is simply necessary, because with the help of it we can revive our site, adding dynamics and more freedom to it. And those who study this language well can even develop their own CMS if necessary.

The purpose of this article is to give a general overview for newbies so that they have an idea of \u200b\u200bwhat PHP can do if they start learning and applying it to their sites.

So what is PHP programming?

PHP is a programming language, just like HTML and CSS.

It is not as difficult to study as it might seem at first to those who decided to take it seriously. Having learned just a few simple functions, you can already apply them on your site, thereby significantly increasing the functionality of your project.

PHP can coexist with HTML in the same document, so you can insert PHP code into already written HTML code. This feature of the PHP language allows the webmaster to achieve the greatest freedom in their work.

What does “add dynamics” mean? What I mean is the possibility of variation on the site, depending on what kind of request the user sets. Whether he asks for some information, or, for example, wants to perform some calculations - these actions become possible thanks to the PHP language.

In short, PHP is used to add functionality to the site. With html alone, you would never achieve this effect!


Here are some examples of what you can do with the PHP programming language:

Mathematical calculations.

PHP can perform all kinds of mathematical calculations - from addition, subtraction, multiplication, division to determining today's date, day of the week and year.

PHP can store user information.

That is, the user can directly interact with the script, for example, enter their data into the contact form or address book, make a request through the search form, add comments to articles, create new posts on the forum, etc.

PHP can interact with MySQL databases.

And when this item is involved, the possibilities are almost endless.

You can put information into a database, you can retrieve it from there. This will allow you to create new pages very quickly, you can develop an admin panel for the site, you can develop a system of logins and passwords, in the end, you can create complex dynamic sites.

With PHP and various libraries, you can also manage site graphics.

For example, you can change the size of pictures, rotate them, change their shade.

Your visitors will be able to edit their avatars, and thanks to this, it is possible to use captcha on the site. You can also, for example, adjust different according to the time of day and seasons.

The list of what can be done using the PHP programming language is so huge that you can list all its possibilities for a very long time.

And this proves once again that knowledge of PHP can be of great benefit and many prospects for a person studying site building, especially those who want to do website development their main activity and make money on it.