Learn php programming language. Personal experience as proof: the PHP programming language is the main one on the Web

Here is a short guide to PHP language for dummies in several parts. I guarantee you will be able to write your first working PHP code after reading this series of articles (or in the process of reading). PHP is one of the easiest programming languages ​​to learn, it is a server-side (server-side) scripting language (interpreted language).

It is used to create web projects. Can be used directly in HTML code. And although the result of the script is often displayed directly in the client's browser, only one browser is enough for PHP to work. That is, you will not be able to run the index.php file directly in the browser, as you probably already did with the index.html file. PHP scripts and web pages created using PHP require a web server to run.

If you don't have a hosting site for your site yet, then I recommend experimenting with PHP scripts on a local server designed for testing projects. To organize a local server in the Windows operating system (WAMP, Windows-Apache-MySQL-PHP), packages can be useful: Denver, XAMPP, AppServ, OpenServer, etc. After installing these packages, you will receive a server already configured and ready for use, and it will be controlled through a convenient menu of the program itself. Also, there are separate implementations of APACHE, MySQL and PHP for the operating system. Windows systems, but you will have to configure them yourself through the configuration files and there will be no menu with checkmarks. To start, restart and stop such a server, you can use batch files *.bat or *.cmd (batch file) with commands to start, restart or stop the APACHE and MySQL services. The third and most difficult option for a beginner is virtual machine with installed and configured operating Linux system(LAMP, Linux-Apache-MySQL-PHP). Ready-made images of such "virtual machines" are often found on the Internet, so you may only need knowledge of setting up programs like VirtualBox or VMware.

Getting Started with PHP Programming for Dummies

  1. PHP code should be placed in the index.php file, the file itself should be placed in the root directory of the site located on the web server.

  1. All PHP code must be enclosed between descriptorsor an abbreviated version, but the web server may not be configured to use a shortened version of this entry, so the first option is preferred.
  2. Inserted PHP code can be anywhere in the HTML code.
  3. Commenting in PHP code is done like this:
// single line comment # another version of a single line comment /* multiline comment */
  1. To view your code, open a web browser and type in the address bar: http://localhost/www/MyEX/index.php

Printing Data to the Screen with PHP for Dummies

  1. Outputting data to a window (the client area of ​​a web browser) using PHP can be done using the echo statement. This operator allows you to display data various types: numbers, character strings, etc.
  2. Output statement syntax:
echo element1, element2, element3, ..., elementN
  1. String data is enclosed in double or single quotes. In double quotes, the code is interpreted by PHP. Anything enclosed in single quotes is output without any interpretation. Example:
< ?php $x="PHP"; //присвоение значения переменной echo "Привет","всем"; echo " "; echo "

$x code example

$x code example

  1. To display more detailed information about a variable, which may be needed when debugging a program, use the var_dump() function. Its syntax is:
var_dump(list of variables);
  1. The variable list specifies one or more variable names. This function does not return anything. Example:
$x=12.56; var_dump($x);
  1. Less informative than var_dump() , the function to dump information about variables is:
print_r(list_of_variables);
  1. For array variables, this function outputs a list of the form index => element.

PHP language variables for dummies

  1. Variables are containers for storing data. The data stored in a variable is called the value of that variable.
  2. A variable has a name, a sequence of letters, numbers, and underscores without spaces or punctuation, always beginning with a dollar sign ($) followed by a letter or underscore.
  3. Valid variable names: $_tel, $tmp, $my_, $address_234_45.
  4. Incorrect variable names: $234tel, my address, $tel:234.
  5. PHP is a case-sensitive language with respect to variable and constant names. However, keywords can be used in any case.

PHP Data Types and Data Transformation for Dummies

Data type Example Description of values
String or character (string) "Hi all"
"123456"
"25 rubles"
A sequence of characters enclosed in quotation marks
Integer, numeric (integer) -234
25
0
A number or sequence of digits that can be preceded by a number sign
Numeric floating point (float) 5.47
21.4
35E-3
A number with a fractional part (35E2 means 3500)
Boolean (boolean, boolean) true
false
This type has two values: true (true, yes), false (false, no)
NULL null This data type has one value - null
Array This data type has one set of values ​​that can be of different types.
Object Program object defined by its properties
  1. In order to find out what type of variable, you need to use the function:
gettype(variable_name);
  1. To explicitly set the type, you can use one of two methods:
Variable_name=(int) 12.45 //result 12 Settype(variable_name, "type")< ?php $x="PHP"; $s=gettype($x); echo $s, " "; settype($e,"integer"); $s=gettype($e); echo $s, " "; $d=(int)24.4; $s=gettype($d); echo $s, " ", $d; ?>

PHP constants for dummies

  1. A constant is a named value that does not change during the execution of a program (script).
  2. Unlike variables, you cannot change the values ​​of constants that were assigned to them when they were declared. Constants are useful for storing values ​​that should not change while the program is running. Constants can only contain scalar data (boolean, integer, float, and string types).
  3. In PHP, constants are defined with the define() function. Here is its syntax:
define($name, $value, $case_sen);

$name is the name of the constant.
$value is the value of the constant.
$case_sen is an optional boolean parameter indicating whether to be case-sensitive (true) or not (false).

define("pi",3.14,true); echopi; //Outputs 3.14

  1. You can use the defined() function to check for the existence of a constant. This function returns true if the constant is declared. Example:
//Declare the constant pi define("pi",3.14,true); if (defined("pi")==true) echo "The constant pi is declared!"; //The script will output "Constant pi declared!"

Differences Between Constants and Variables in PHP for Dummies

  1. Constants do not have a dollar sign prefix ($).
  2. Constants can only be defined using the define() function, not by assigning a value.
  3. Constants can be defined and accessed anywhere without regard to scope.
  4. Constants cannot be defined or invalidated after the initial declaration.
  5. Constants can only have scalar values.

PHP programming for dummies. Part 1 was last modified: March 3rd, 2016 by Admin

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

Why learn php and MySQL?

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


Though the importance of PHP has decreased a bit in our time. And all because of the large number of engines that (ironically) are also built on the basis of this language.

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

Each CMS is a software framework provided with a user interface. Its toolkit greatly facilitates 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.

To begin with, not many people have the patience, time, or energy to learn PHP and MySQL. A person must come to this on his own. But the one who dares to comprehend these disciplines will receive:

  • Demanded profession - smart programmers have always been in great demand in the labor market. But even inexperienced beginners with a 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 do programming, it is not necessary to get up early, get to work and follow the dress code. All this can be left behind the threshold, and you can create program code while sitting at home in slippers;
  • Saving money - if you are a website owner, then you certainly know that the services of professional web programmers are expensive. And for a beginner on the Internet, every penny is precious. Selfeducation MySQL and PHP will save money and put them on track.

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

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

  • An interesting hobby - web programming is not only a means of making money or saving money. It is also an exciting activity that combines both a technical 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 hosts on the Internet. On its basis, the main part of dynamic sites is written.

In a dynamic site, unlike a static one created only on html, the content of all pages is formed in response to a user request. The structure of the resource is formed based on the 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 remote files;
  • XForm support ( forms based on XML);
  • Approximation of PHP syntax to the C language;
  • Lack of strong typing – variables are typed 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 web space.

What is MySQL?

MySQL is a free DBMS from Oracle. Together with free version development and commercial releases under the order. It is thanks to this that all new developments of the corporation are necessarily introduced into free editions of the DBMS:


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

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

  • Work is supported both with local sources and with remote ones;
  • Built-in support for a large number of table types. And thanks to open source the list of supported table types is growing;
  • Wide range of cross-platform;
  • 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 you can learn about the capabilities of the DBMS from any tutorial or reference on MySQL.

Where to begin?

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


A few best options:
  • Apache HTTP Server - can be downloaded from the official website of the developer;
  • Denver is the best option for installation and further use. The installation package includes the 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. As well as the 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 need an editor that supports the syntax of this language. Some of the best options:
  • PHPEdit ;
  • Microsoft Web Matrix ;
  • Kantharos PHP IDE
  • Adobe Dreamweaver.

Sandbox

server god July 25, 2013 at 01:07 pm

PHP from scratch. Lesson 1

  • PHP,
  • Programming

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, as well as write our first script.

Syntax basics:

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

Output text information - echo (can output html code)

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

Lesson 1. Creating the 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 a Script.test folder in the hosts directory, in which, in turn, create a folder

WWW. In the WWW folder, create an index.php file? into which we transfer the contents of our file.

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

And voila! We see the inscription Hello World!

How not to write Hello World:

Hello World Not spelled like this

So:

Well, it certainly isn't:

Completion.

On this, our lesson came to an end, but in the end, a small selection of useful links:
denwer.ru - site where you can download Denwer
en.wikipedia.org/wiki/PHP - What is PHP
http;//php.net - PHP tutorial

tags: PHP

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

From the author: On the World Wide Web, physical strength means nothing! You can press the keys with any force, but the result will not change. On the Internet, the one with more experience and knowledge is considered stronger. Although my friend “pumped up” the hardware of his PC so much that he became afraid of it! But this is with everything from the "iron" opera. And today we will find out in PHP where to start learning to become a strong programmer.

"Tea" disease

Of course, sorry, but you are a "teapot". How did I guess? Well, because only beginners ask themselves such questions. And there is nothing offensive in this “title”, because you have so much desire for learning that you can “boil”. And this is a sign that everything will work out!

The study of PHP, like any other science, should be started from the very beginning, that is, from the theory. You need to understand what this programming language is: its capabilities, main scope, features, and so on. This is an important aspect, since beginners, due to the lack of basic theory, general ideas about a particular language, often make the wrong choice. And after that, with deceived expectations, they quit training after several hours of “research”. I will try to lift this veil a little so that you understand not only where to start learning PHP, but also why.

A few features of the language that beginners should know:

Most often, PHP is used in website building, but it can also be used to develop client applications.

It is a server-side language - its code is executed on the server side, so you will need a local server or an appropriate assembly to learn.

Close relationship with - if you are going to “storm” site building, you will also have to learn the specified DBMS. We will help you with this.

Where is the beginning?

If you are going to learn PHP programming, but don’t know where to start, then this section is for you. You should start with the basics: with the syntax of the language, data types, variables, their initialization, loops, function declarations, etc. Even if you studied all this in other software disciplines, you will have to read it again, since PHP has a number of features.

But it will be later, but initially you need to decide on the main literature for comprehending software science. The choice of sources should be approached very seriously.

Choose a few, and read a couple of pages from each. The presentation style of the main source should be as simple and clear as possible. The success of education as a whole depends on this.

To comprehend PHP, you can use various tutorials, specialized manuals for "dummies". It would be nice to add one or more sensible ones here: the visualization of information significantly increases the assimilation of the material. But once again I repeat: where to start learning PHP and the choice of sources is up to you.

A little personal

In general, after the first semester, in terms of academic performance, I slipped to the very bottom. And all because the teachers, seeing that most of the students "swallow" all the material, even "not chewed", tried to give as much as possible. But I did not have the experience that my groupmates had.

The next semester, I transferred to a parallel group consisting of the same “dummies”. For them, the teachers “bited” and “chewed” everything, carefully explained. Here things went "on the mend", and I again became one of the best students.

I am not boasting (well, maybe a little), but I am trying to explain that you should choose the style of learning, methods of obtaining information and the duration of comprehending the discipline for yourself. In my opinion, various are an ideal source of educational information. Their selection is what you need to start learning PHP from scratch.

What you need to start development

PHP is a programming language whose code is executed on the server side. Therefore, to work with it locally, you need an appropriate software. Three main components:

PHP interpreter.

local server.

But installing each of these components can take a lot of time and effort. Especially if you are a beginner. The best option is to install a software package that includes all the components.

I recommend using Open Server. It includes everything you need to get started with PHP without much headache. The installation process is automatic (easy and fast). Just what you need for real "dummies".

I hope I managed to dispel all the doubts and questions that "haunt" newcomers. Do you feel like you've gotten stronger? You are just getting started with PHP. Soon you will be real "strongmen" in the software sciences. See you for new workouts!

Good day, dear readers of my blog. Somewhere I heard that every person in his life must go through writing poetry. The situation is changing and now every second person thinks about writing code and creating their own website. Many merge at the moment, others cannot decide on the engine in any way. If you finish reading this article and move on to learning according to my recommendations, I am almost sure that you will succeed.

The topic is quite complex. Today we will talk about how to write a website in php from scratch. Let's take a closer look at what these cherished three letters mean and you will learn about better ways not only learn, but really understand php.

What is PHP?

It's a little strange to start this article with this question, because it is assumed that you already know everything and therefore are ready for difficulties. But, my blog is for beginners. Be indulgent, let's repeat the information.

In simple and accessible terms, php is a programming language specifically designed to script a web application that runs on a web server. This is a fairly popular programming language, as 85% of websites use it.

The peculiarity of this language is that it is universal, easy to learn and opens up your opportunities not only as a programmer, but also as a businessman. As a result, you will be able to write and develop your projects on your own. Without anyone's help.

We study effectively

Many began to learn this language, but few reach the end. For effective learning, the first thing you need to do is find a source of information, a book, a tutorial or a video, but more on that later.

Then we need to download the compiler. This is a program that reads your script line by line as a statement and executes it.

The most common compiler is denver, a simple and free package. desired programs with which you can write scripts. If you ask my opinion, then I would advise you to download Open Server. He's gaining momentum now. It is a head taller than Denver and will be more comfortable for you to work in.

What do these packages do? They allow and work on it as on a server. It is not necessary to download anything right now. You will hear more than once about useful software from this series in any training course, but you will need it.

The essence of effective learning is that after going through the lesson, you should try to put everything into practice. If theory is supported by practice, then in a few weeks you will have a basic language skill.

Books for learning

Let me tell you, I am not a fan of books. When it comes to internet technology. It's like explaining to a Masai man what wi-fi is. No drawings will help to understand everything normally. Nevertheless, I want to provide you with a small list of php books for dummies that are listed among professionals.

I would like you to really achieve your goal and if it seems to you that this training option will suit you better, I will be happy to provide information.

PHP and MySQL. Web application development This is a great book for a beginner. First of all, the author will show how to set up Apache (HTTP server), PHP and MySQL (database), then he will tell you how to choose a code editor. The book covers: the syntax of the language, the most useful functions, creating your own engine and a number of other functions.


In general, nothing surprising is not it? But nevertheless, it is a real textbook with unique information that you will not find anywhere else. This is the fifth edition, so there will be no outdated information. The book was released in 2015. In order to start to get acquainted with the code yourself - that's it.

HTML, JavaScript, PHP and MySQL. Webmaster's Gentleman's Set - This is a more detailed tutorial on learning php. It touches on several other useful ones, without which the full creation of web applications is impossible.

Easy to read, suitable for self-study and student learning. The author covers such topics as: PHP basics, dynamic page generation with CSS (cascading style sheet), database administration, creating dynamic pages with JavaScript.


Build dynamic websites with PHP, MySQL, JavaScript, CSS and HTML5 - I would recommend this book to more advanced readers who already have basic HTML layout skills. If you have ever studied this and still remember the basic principles then this book is for you.


PHP and MySQL. From beginner to professional - and the book of Kevin Jank completes our review, in which the author makes a strong bias towards creating web applications with a database.


The book is very easy to read and is perfect for self-study.

YouTube video

From my own experience, I will say that learning php from YouTube videos is quite difficult. Even though they seem simple. Unlike the Photoshop tutorials that I love, learning programming languages ​​on YouTube is simply impossible. Even a video that is only 15-20 minutes long causes a lot of inconvenience.

Such videos can discourage you from typing the code yourself. Why, if the author has already done everything for you: typed, launched, showed with a specific example how everything works? As a result, remembering something is almost impossible.

Tutorial

In my opinion, this is the perfect learning experience. It's great to have an expert with you.

Each lesson is accompanied by comments, you can ask questions to experts, calmly discuss and solve incomprehensible points. You don't have to surf the internet looking for information. Everything will be chewed and put in the mouth, all that remains is to use it.

You will be given a task and will see how well you do it.

I can recommend you course on netology . This training center is valued among professionals, and in just two months you can learn everything you need. Sets in the group occur constantly.

Don't worry if you don't understand something. That's what the course is designed for you to learn. This is real step-by-step instruction for newbies. Don't believe? Download full program course from the official website and you will be convinced of this.


If you dream of learning how to create sites without, on your own and in php, then this is the best option for you.

mob_info