PHP programming language for dummies. Simple sample programs


The PHP language confidently finds itself in the top of the most popular programming languages, but everything has an end. Is PHP in danger of falling into oblivion, what could replace it, and what language would you choose to create a site like Facebook? These questions were answered by users of the website Quora.

George Mauer, teaches JS

PHP is dying, Java is dying, C# is dying, SQL is dying, JavaScript is dying, C is dying. And yet there are significantly more projects in these languages ​​than projects in all non-listed programming languages ​​combined. Yes, sometimes new trends can displace something established, but this process happens extremely slowly. This does not mean that the oldest is bad.

I can't agree that PHP was the best option For creation of Facebook. The creators of this social network actually only partially use PHP. Nowadays it can be said that instead of this language they have their own dialect called Hack. PHP was simply the language in which Zuckerberg and other developers began working on this project.

That's not to say that PHP was such a bad choice. Yet it is a language that meets the requirements of rapid application development. And this, in turn, is one of the key factors for a startup - in the case of Facebook, this factor played a decisive role. Initially, PHP was a kind of collection of scripts. And this makes it easy to move to a lower level of abstraction and create C code when there is actually a need for optimization. All this has been carefully studied and successfully implemented into most modern languages.

Please get the idea out of your head that social network requires something specific from the programming language. Most of the code generation will be completely standard and familiar. Yes, there are some problem areas like matching supposed and potential friends, but similar issues are most often solved with the help of specialized software. For example, graph-oriented databases. You will need to be extremely careful and careful in building your system, and also have a good understanding of DevOps, but the same will have to be done with other languages. Instead of having a perfect development language, what is more important to you is experienced and knowledgeable developers.

And this, in fact, brings me to the crux of the matter. PHP is extremely attractive if only because great amount specialists for this moment they know him well. But you probably don't want any of these specialists working on your startup. You will want to hire people who speak several languages, people who have a well-formed and informed worldview. And most of these people don’t really like PHP.

Imagine: I’m sitting in a brand new office rented for the development of my just registered startup, staring at my desk with a bunch of money received for the development of the project, and racking my brains over which programming language to choose. I understand that this is problem somewhere around 250 on the list of things that will determine the success or failure of my future venture. And I'm starting to realize that this decision needs to be taken together with a development team, which I don't have yet. Therefore, I myself am starting to look for language options that would be relatively widespread, would easily allow developers to move to a lower level of abstraction and, most importantly, in which I would have familiar developers who are the best in their business.

At the moment, such a language is Elixir. It is based on virtual machine Beam is a fairly close relative of the Erlang language, which has demonstrated itself well in a number of projects over the course of several decades. In addition, this language shows simply unimaginable performance results.

To others excellent choice could become the Go language. Mainly it's the language low level, but you can do everything in it that you can do in languages high level. Even though I don't like some of the decisions regarding its structure, it still deserves attention one way or another.

Another option would be Clojure. There is a chance that it won't be easy to find developers for this language, but given that this language is a direct descendant of LISP, I can honestly say that it is incredibly powerful and gives many options for development.

A few important notes:

  • take a look at F# on the .Net framework or even the ubiquitous C#. If you do choose the latter option, be prepared to have a lot more resumes to review and sift through to build a great team;
  • You can do some impressive things with Scala;
  • Node.js. I just have to mention Node.js. Personally, I think Javascript is at the top of the chain at the moment, but Node has also been on the list of fairly widely used languages ​​for a long time. In addition, there is a large number of highly qualified specialists.

This site already has articles about and given. Now we'll talk about what PHP is.

What is PHP and what can you do with it?

This easy-to-follow introduction to the PHP language explains the basics of PHP and how you can 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 full-fledged blogging system, online store, or forum. More .

PHP - server-side language

PHP is known as server programming language. It means that it runs on a web server. Most web programming languages ​​are server-side languages, but some, like JavaScript, are client-side, meaning they run in the web browser.

Server-side languages ​​give you more flexibility, since you can do things that are difficult to do with using JavaScript- for example, working with files, databases, or working with images. It must be said that JavaScript has spread very quickly these days.

Executing server side code is more in a safe way than on the client side, like JavaScript does. Because the JavaScript code sent to a web browser and is easy for site visitors to view and edit. Even on one page of the site you can easily. 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 executes PHP scripts there.

PHP is open source software

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

PHP is focused on web application development

While many programming languages ​​can be used to create web applications, PHP is one of the languages ​​specifically designed for use on the Internet. PHP has many useful web functions such as:

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

You can mix PHP code with HTML code

One of the wonderful PHP function is that you can include blocks of PHP code in HTML pages.

You can separate PHP blocks using special characters. When the web server receives information about the page,
all PHP blocks are executed 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. Regular PHP applications, include:

After reading the article, you can consolidate your knowledge by completing a short tutorial that is based on the material in this article. Good luck in mastering the PHP language!

It is well known that PHP is a dead programming language and its 22-year-old ecosystem became virtually useless when Node and new asynchronous frameworks based on it appeared. The superiority of Node is obvious because everyone knows that single threaded asynchronous programs more better default. And faster.


“But Simon! Why?!", you'll probably scream when you see this text on the screen. Here's why:

Job prospects

PHP developers are not in demand. After 22 years, all the companies using PHP immediately abandoned it as soon as Node v0.0.1 was released because it instantly became the best development stack. In addition, everyone knows that for a successful launch (let's forget about Slack) you need to create web interfaces in Node and store data in MongoDB.


Otherwise it is simply impossible to achieve success.


Here are some scientific facts to prove these statements:

$title = 'PHP developers can't find work to support their families';

Ecosystem of language

The ecosystem is probably the most important factor in deciding not to use a programming language. Luckily for us, PHP has been around for a long time, and its ecosystem is full of large, well-supported, full-featured frameworks that everyone hates - like Laravel, a sort of Rails equivalent, or enterprise solutions like Symfony and Zend.


Unlike PHP, Node developers don't have to worry about finding a framework to hate because everyone just writes their own. By creating their own frameworks, a developer can truly differentiate themselves from the competition by reinventing the wheel in a way that only makes sense to them (the developer). This practice also doubles the job security, which is very important, as shown in the scientific research results above. It also triples the Developer Cool Factor™.


Stunning evidence of the excellent Node ecosystem can be seen in the graph below:



$title = ‘The more frameworks, the better’;

Time costs

The real level of productivity of a developer can only be measured by assessing how he spends his own time. It can be seen that PHP developers spend more time on writing code and building functional applications than on cultivating the Developer Cool Factor™ and earning stars on GitHub. This will obviously impact them negatively when working at a startup because they are using their time unproductively. We all know that GitHub stars are a quantitative way to evaluate a developer's skills.


The failure of PHP developers to contribute to the community is shown below:





$title = ‘Listening to complaints is less productive than complaining. Fact.';

Things you can't do as a PHP developer

  • Program asynchronously (for real!);
  • Get a simple and understandable sequence of parameters for standard library functions;
  • Create your own own template React TODO MVC applications;
  • Implement a full-fledged backend on the server side with a frontend on the client side;
  • Create your own memory leaks;
  • Make the space meaningful;
  • Achieve data loss between requests;
  • Solve the problem of world hunger;
  • Program in JavaScript;
  • Admit to people that you are a PHP developer.

PHP as a business tool

We all know that PHP is definitely inferior and cannot be used in business application development, so here is a list of failed businesses using PHP compared to the list successful companies, selling their products based on Node:



$title = 'Node is great and effective tool evil';

Conclusion

Every developer knows that the fastest and most effective way to get anything is to complain a lot and start from scratch every time. The market will always be waiting for the launch of your startup, because first of all you need to finish creating your own framework.
Besides, why should we worry about offloading the work and relying on the open source community when we can just do everything ourselves?

From the author: Is it necessary to know the PHP programming language? If you are going to throw in your lot with website building, you will have to. Even if you really don’t want to! Why is that? We will try to answer all the common “whys” associated with this language in our material.

The solution that “holds” the Internet together

This is exactly how one of my acquaintances, who has been creating Internet resources for more than a decade, described PHP. And he’s right, probably 200% percent (or maybe more).

The history itself of this language suggests that he was born to “blind” the current version of the Network to which we are so accustomed. This is probably why some people still cannot realize its power, even after learning the basics of PHP programming.

Proving the role of PHP in creating the Internet is a thankless task. Here, as they say, supporters of others can begin to speak out server languages. 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, shouting and waving your arms, extolling your programming language, which you specialize in, is a simple matter. But the best “evidence” indicating the demand for PHP is its prevalence.

The following rating of program languages, compiled by TIOBE specialists last summer, tells us that PHP already has been consistently ranked among the top for several years. You haven't started searching by programming language yet PHP tutorial? You'll be running soon.

If you are wondering why Java has jumped so much, then the answer is: thanks to the Android mobile operating system, applications for which are developed in this language.

Own rake

Back in the early 2000s, I was engaged in “research” in the field of programming. I kept trying to figure out which “party” of developers I should join, which discipline I should devote my life to studying.

In principle, I did not consider PHP as a programming language for beginners. He seemed too confused. Here's the other thing about ASP.NET: a commercial language based on C#. Oh, what castles in the air I built back then! And there were all the prerequisites for this:

The technology was developed by such a “thought giant” as Microsoft.

Availability of specialized software – 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 the excellent visual editor it only took a few minutes to create a web page. By dragging and dropping controls and styling them in the editor, you could make a website in less than an hour!

But the PHP programming language from scratch didn’t work out for me right away. Honestly, I tried to make friends with him (I had to pass the exam somehow). But when studying its basics, it seemed callous and even cold to me.

In general, I took up ASP.NET. I created my first website. Well, everything seems to be working in the development environment. Cross-browser compatibility checked in several popular browsers. I think it's time to "fight." So to speak, show your “brainchild” to the whole country (at least). This is where the “rakes” turned out to be.

My attempts to find hosting with ASP.NET support on the RuNet were never successful. There were, of course, several paid platforms, but the prices for hosting a website on them were clearly not “student” prices.

Somehow I dug up in Burzhunet free option hosting (by the way, sponsored by Microsoft). Well, I clicked, enjoyed the breadth of my thoughts, but things didn’t go any further. And all due to the fact that most of the sites were already made in PHP.

Once you decide and understand exactly what you are ready to study PHP language programming, look for a tutorial for beginners “to suit your needs.” The main thing is that you understand what the author of the publication wants to convey to his readers. Immediately get ready to pay a good amount of money for quality literature.

But it’s better to take an integrated approach - add a smart one too. This will allow you to hone your skills right away practical examples. And my advice to you is to do less copy-pasting code! I’ll explain why now.

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

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

Well, let me take my leave for today. Forgive (if anything) for the excessive overview of the content of the article, but this is necessary to understand the features of this language (after all, it is server-based). I wish you to quickly grasp the basics of the PHP programming language and start real coding!

8 months ago | 35.9K

Hello everyone, my name is Sergey Nikonov, for those who don’t know me, I’ll tell you a little about myself. I have more than 10 years of experience in developing websites and web applications, and in this video I will try to answer one of the most frequently asked questions - Which programming language should I learn first?

Watch the video The first programming language. Which one to choose in 2018?

The programming language itself is simply a tool through which this or that goal is achieved, and all object-oriented programming languages ​​have common properties, such as variables, arrays, functions, methods, classes, interfaces and other properties.

And when you learn to use these properties at least at an intermediate level in one programming language, you can very easily get used to any other programming language.

But I also want to emphasize that do not try to learn all programming languages ​​at once, like some students, they tried a little, for example, writing in Java, after a couple of days they switched to Python, then to . As a result, with this approach, they did not master a single language, since there is a lot of information that needs to be learned, students have a mess in their heads, and at the same time they lose motivation to study programming at all.

Therefore, until you have learned one programming language at least at an intermediate level, do not switch to another.

Which programming language should you choose as your first?

I recommend choosing PHP, as this language is very simple, has a huge community, and also a large number of vacancies around the world if you want to learn programming in order to change your current profession.

Someone may object, say that PHP is slow, bad code is written in it, etc. but one of the clearest examples is the Facebook website. It is written in PHP and the Facebook site is ranked 2nd in terms of traffic in the world, among millions of websites. By the way, the social network VKontakte is also written in PHP.

As for bad code in PHP, this is possible, since the language itself gives a lot of freedom of action and if PHP is not learned correctly, your code will be confusing and the site will be slow. I will tell you how to properly learn PHP on your own and in what order in one of the following videos.

Quite often I get asked the question:

First of all, you need to understand that HTML is a markup language, not a programming language, and refers to the layout of html pages. With the help of , you explain to the browser what your page should look like, what size and color the blocks on the site should be.

How to start programming in PHP?

Programming in PHP is very easy and all you need is







2024 gtavrl.ru.