• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

PHP Cheat Sheet for Beginners

Lomanu4 Оффлайн

Lomanu4

Команда форума
Администратор
Регистрация
1 Мар 2015
Сообщения
1,481
Баллы
155
Note: I am primarily using this as a study tool as I'm upskilling my foundational knowledge. With this in mind, this document is ongoing, and I'll likely be updating it weekly.

Opening and closing tags:


<?php ?>

Note: omitting the closing tag at the end of a file can be beneficial so you don't have any unwanted white space at the end of the file

Printing:


echo 'This prints to the screen.';
<?= 'This works too.'; ?>

Commenting:

One line:


# This is a one-line comment in PHP

Multi-line:


/* This is a multi-
line comment in PHP */

Checking variable type:


var_dump($var_name);

Comparing Floats:
Note: Comparing floats in PHP is tricky because of precision. The following is a workaround for that limitation.


<?php
$a = 1.23456789;
$b = 1.23456780;
$epsilon = 0.00001;

if (abs($a - $b) < $epsilon) {
echo "true";
}
?>

String Definitions:


'this is a string'

"this is a string"

<<<END
this
is also
a string
END

<<<'EOD'
This is an example of
another type of string
you can use in PHP.
EOD

String Interpolation:


<?php
$juice = "apple";

echo "He drank some $juice juice." . PHP_EOL;

?>

or


echo 'this line prints a {$var}';

String concatenation uses a . rather than a + in PHP.

I used PHP's documentation as the source of my information here. Some of the code will be similar or identical.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу