Php learning from scratch. Learning PHP and MySQL correctly


Knowing HTML gives you an idea of ​​how to create websites. And it even gives you the opportunity to independently develop Internet resources. However, the use of this markup language is limited due to the static nature of the pages created with its help. In particular, it is used in most cases for the development of business card websites. The thing is that if you need to make any changes, you need to edit each page separately, and if the resource has several dozen or hundreds of them, such a process will not only be tedious, but also drawn out over time.

To optimize site administration, you can use PHP (an acronym for PHP: Hypertext Preprocessor), a scripting programming language that allows you to create dynamically populated web pages. Its use makes it possible to make the resource truly interactive, and the site management process simple and less expensive in terms of effort. The online PHP course for beginners from WebShake helps you master the basics of a scripting language from scratch, learn how to create dynamic resources that are easy to modify and maintain.

Our text materials and video tutorials are designed to be understandable to every user who wants to learn web programming. And the homework assignments located at the end of each topic will allow you to consolidate the acquired knowledge and hone their application in practice.

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 very history of the emergence of this language suggests that it 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 other server-side languages ​​can begin to speak out. 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 ranking of software languages, compiled by TIOBE specialists last summer, tells us that PHP has been consistently in the top for several years. Haven't you started looking for a tutorial on the PHP programming language yet? 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 - the powerful Visual Studio editor.

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, creating a web page took only a few minutes. 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. I checked cross-browser compatibility 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 found a free hosting option in Burzhunet (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.

After you decide and understand for sure that you are ready to learn the PHP programming language, look for a tutorial for beginners “for yourself.” 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 immediately with 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 and remember the features of 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!

I’ll try to write recommendations in free form for the first few points.

First and most importantly, to learn PHP programming well, you need to learn programming well. This is a very important thing. Most people writing in PHP don't have the slightest idea about programming. Even about such basic things as code formatting, debugging, profiling, error handling, file operations. You may notice that I'm not talking about OOP. This is a completely separate topic; OOP must be taught specifically. Unfortunately, out of 100 people who say they know OOP, 90 are banal copy-pastors who have learned the syntax, but do not understand the meaning of objects. But to play chess, it is not enough to know how the pieces move.

It would also be nice to answer yourself the question - why do you want to learn programming in PHP? The question is not at all idle. Many people mix up a bunch of different concepts in it. For example, CMS has already been mentioned here. and indeed, if we are talking about making money, then customizing Jumla and writing shitty modules for it are much more financially profitable than the ability to write something from scratch. For freelancing, anyway.

In general, PHP can be used in many different ways. And for each case it will be its own language.

  • You can create a guest or business card website using “naked” PHP - and there is nothing bad or shameful about it. On the contrary, this is a plus of a language that is suitable for such purposes, without dragging along a couple of million lines of code for the sake of a site of five hundred.
  • You can write a professional portal, using one of the existing frameworks as a basis, and develop it.
  • You can write a custom highload project, for which you will need to write your own framework, again using bare PHP.
  • You can, as already mentioned, rivet sites based on some kind of CMS.

Lots of options! so you need to first decide what you want.

They talked about JS+CSS above - don’t listen, it’s complete nonsense. Frontend programming is a completely separate thing, much more visual than abstract. And, thank God, more and more employers are starting to understand this. Although, again, if you freelance and are a jack of all trades, then you can’t live without it.

But if you work as a hardcore server programmer in a team, then you only need to have a general understanding of HTML/JS/CSS (since texts in these languages ​​are, in fact, practically the only result of PHP’s work).

But what you definitely need to know well from related technologies is the HTTP protocol, file system structure, and working with the command line in Linux.

Now for the rest

Mysql is still the cornerstone of data storage on the web. You need to know and understand joins and indexes

Frameworks are a must. Here, however, there is a problem of choice, but there is no fundamental difference between them. Yii is a good choice.

You don't need Github, you don't need to know it. You need to know git.
But what is mandatory for a web programmer is the ability to use Google. At least at the level of ability to copy-paste an error message into a search form or write a question “What is git” ;-)

Because to work in a team you need to know some version control system, and git is a de facto standard. Understand the principle of operation and basic commands - checkout, commit, push.

PHP (P HP: H hypertext P reprocessor, thoughtful preprocessor

Hypertext) is a scripting programming language focused on the web.

In lesson 1 we will get acquainted with the basic syntax and also write our first script.

Basic syntax:

-
- start and end of the script
assignment operator - =

Output text information - echo (can output html code)

While(loop condition)(action) - loop
- if(condition)(action performed if the condition is false)else(action performed if the condition is false) - condition
-

Lesson 1. Creating your first script

As you can see, the script consists of one line.

To execute the script you need the appropriate software; for Windows users I recommend Denwer (http://denwer.ru)
After installing Denwera, create the Script.test folder in the hosts directory, in which we in turn create a folder

www. Do we create a file index.php in the WWW folder? into which we transfer the contents of our file.

After saving the file, restart Denwer. Then type script.test in your browser

And voila! We see the inscription Hello World!

How to write Hello World inappropriately:

Hello World Not spelled like that

So:

Well, it's definitely not like that:

Completion.

This concludes our lesson, and at the end there is a small selection of useful links:
denwer.ru - site where you can download Denwer
ru.wikipedia.org/wiki/PHP - What is PHP
http;//php.net - PHP tutorial

Tags: PHP

This article is not subject to comment, since its author is not yet a full member of the community. You will be able to contact the author only after he receives

There are disciplines in web programming that any person associated with the World Wide Web must know the basics of. Therefore, one way or another, you will have to learn PHP and MySQL. And if you don’t want to, then greed will still force you:

Why learn php and mysql?

This question can only be asked by those who are completely unfamiliar with the specifics of building a web space and its modern basis. Any person more or less knowledgeable in programming will say that these two disciplines are currently dominant on the World Wide Web. This means that almost the entire Internet is built on the basis of PHP and MySQL:


Although nowadays the importance of PHP has decreased a bit. And all because of the large number of engines, which (ironically) are also built on the basis of this language.

In the modern web world, engines mean any content management system (CMS). Most of them are written in PHP and MySQL.

Each CMS is a software framework equipped with a user interface. Its tools greatly facilitate the process of site administration. But then why bother learning PHP from scratch? After all, you can simply go to the administrative part of the resource and perform all the manipulations using the tools built into it.

Let's start with the fact that not many people have the patience, time or energy to study PHP and MySQL. A person must come to this himself. But those who decide to comprehend these disciplines will receive:

  • A profession in demand - smart programmers have always been in great demand on the labor market. But even inexperienced beginners with good theoretical knowledge of PHP and little experience in web programming will be able to find a job with decent pay;
  • Remote work – in order to engage in programming, you don’t have to get up early, get to work and follow a dress code. All this can be left outside the door, and you can create program code while sitting at home in slippers;
  • Saving money - if you own a website, then of course you know that the services of professional web programmers are expensive. And for someone starting their own business on the Internet, every penny is valuable. Self-studying MySQL and PHP will save money and put it in the right direction.

As already noted, most modern engines are based on PHP. Although their fault tolerance is at a high level, the influence of the human factor has not been canceled. Therefore, CMS code sometimes behaves differently than the web programmer intended.

And to correct this mistake, you need to look for a specialist and pay him a lot of money. And then it turns out that the whole problem was in just one line of code, which could be easily fixed even with knowledge of only the basics of PHP.

  • An interesting hobby - web programming is not only a means of making money or saving it. This is also an exciting activity that combines both a technical element and a creative component.

Learning PHP and MySQL can be a means of self-expression for many.

What is PHP

PHP is a scripting programming language. It is most often used to create web applications and web services. This language is supported by most hosting sites on the Internet. The bulk of dynamic sites are written on its basis.

In a dynamic site, unlike a static one created only in html, the content of all pages is generated in response to a user request. The resource structure is formed based on template files, and the content is (most often) loaded from databases.


The popularity of PHP is due to its following characteristics:
  • Support for most popular DBMS ( Database Management Systems);
  • Automatic sending of HTTP headers;
  • Built-in support for working with sessions and cookies;
  • Tools for working with deleted files;
  • XForms support ( XML-based forms);
  • The proximity of PHP syntax to the C language;
  • Lack of strict typing - variable typing is done dynamically.

Data types are where you start learning PHP

  • OOP support ( object-oriented programming);
  • A large set of superglobal (predefined) arrays designed to work with the web space.

What is MySQL?

MySQL is a freely distributed DBMS from Oracle. Along with the free version, commercial releases are also being developed to order. It is thanks to this that all new developments of the corporation are necessarily implemented in free releases of the DBMS:


Features of the MySQL DBMS:
  • Support for data replication mechanism starting from the first releases of MySQL.

Replication is the process of synchronously copying all changes to a source on several of its copies at once. That is, any action on the data of one copy of an object will be reflected in all its other samples.

  • Work with both local and remote sources is supported;
  • Built-in support for a large number of table types. Moreover, thanks to open source, the list of supported table types is increasing;
  • Wide range of cross-platform functionality;
  • The size of MySQL database tables is limited only by the capabilities of the operating system on which the DBMS is deployed;
  • Support for most popular programming languages ​​via API ( application interface).

More detailed information about the capabilities of the DBMS can be found in any tutorial or reference book on MySQL.

Where to begin?

From the bitter experience of many beginners, we can conclude that the main problem with self-learning PHP and MySQL is choosing the right software. And all due to the fact that PHP is a server-side programming language. Therefore, to test the code you need not only a special editor, but also a local server:


Several optimal options:
  • Apache HTTP Server – can be downloaded from the developer’s official website;
  • Denver is the most optimal option for installation and further use. The installation package includes an Apache server, PHP and MySQL. In the first option, you would have to download and install all this separately.
  • XAMPP is a suite that includes PHP and MySQL. And also a built-in PHP tutorial:
Both suites include a utility for creating and modifying MySQL-based databases using T-SQL queries. But to write code in PHP, you will need an editor that supports the syntax of this language. Some of the most suitable options:
  • PHPEdit ;
  • Microsoft WebMatrix;
  • Kantharos PHP IDE;
  • Adobe Dreamweaver.






2024 gtavrl.ru.