https://www.schoolofnet.com/curso/php/linguagem-php/iniciando-com-php/
- Introdução
- Dicas para iniciantes com PHP
- Instalando PHP no Windows
- Instalando PHP no Linux
- Instalando PHP no MAC
- Qual IDE devo usar
- Primeiro exemplo com PHP
- Operadores aritméticos
- Variáveis e tipos de dados
- Como o compilador do PHP trabalha
- Strings
- Precedências
- Comentários
- Arrays
- Arrays com chaves e valores
- PHP no browser
- PHP com HTML
- Passando informações entre páginas
O PHP (um acrônimo recursivo para PHP: Hypertext Preprocessor) é uma linguagem de script open source de uso geral, muito utilizada, e especialmente adequada para o desenvolvimento web e que pode ser embutida dentro do HTML.
php -v
PHP 7.2.1 (cli) (built: Jan 4 2018 04:29:12) ( ZTS MSVC15 (Visual C++ 2017) x86 )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2017 Zend Technologies
01-PHP-Basico\primeiro-exemplo.php
<?php
echo 'School of net ';
echo 'Iniciando com PHP';
echo 450;
echo 1000.02;
- 01-PHP-Basico\08-Operadores-aritmeticos.php
<?php
echo -10 - 4 - 100; // -114
echo "\n";
echo 4 + 3; // 7
echo "\n";
echo 4 + (3 - 2); // 5
echo "\n";
echo 5 * 6; // 30
echo "\n";
echo 5 / 6; // 0.83333333333333
echo "\n";
echo 4 * 5 / (6 + 3); // 2.2222222222222
echo "\n";
echo 5 / 0; // Warning: Division by zero in \01-PHP-Basico\08-Operadores-aritmeticos.php on line 14
echo "\n";
echo 2 ** 3; // 8
echo "\n";
echo 5 % 3; // 2
echo "\n";
- 01-PHP-Basico\09-Variaveis-e-tipos-de-dados.php
<?php
$nome = "School of Net";
echo $nome;
$nome = 'Iniciando com PHP';
echo "\n";
echo $nome;
$nome = 5000;
echo "\n";
echo $nome;
$numero = 5000;
echo "\n";
echo $numero;
$NOME = 'school of net';
$NOME234 = 'school of net outra variavel';
$nome2213nome = 'asdfasdf';
$primeiro_nome = 'luiz';
$primeiroNome = 'luiz';
$variavelTrue = true; //booleano
$variavelFalse = false;
echo "\n";
echo $variavelTrue;
echo "\n";
echo $variavelFalse;
/*
School of Net
Iniciando com PHP
5000
5000
1
*/
- 01-PHP-Basico\11-string.php
<?php
echo "alsdjflksjdhfksdjfhkjh";
echo "\n";
$variavel = "School of Net
asdfhgasjkdhfgajksdhfghjsdgfhjasdgfjasdgf
asdfasdfasdfasdfasdfasdfasdf
asjlkdfhalskdjfhalsjkdfhalskdjfhalsdkfjhasldkfjh
";
echo $variavel;
echo "\n";
$string1 = "School of Net";
$string2 = "Iniciando com PHP";
echo $string1 . $string2;
echo "\n";
echo "Luiz" . " Carlos";
echo "\n";
echo $string1 . ' ' . $string2;
$string3 = $string1 . ' ' . $string2;
$string3 = "School of Net Inciando com PHP";
$string4 = "$string1 $string2";
echo "\n";
echo $string4;
$string5 = '$string1 $string2';
echo "\n";
echo $string5;
php .\11-string.php
alsdjflksjdhfksdjfhkjh
School of Net
asdfhgasjkdhfgajksdhfghjsdgfhjasdgfjasdgf
asdfasdfasdfasdfasdfasdfasdf
asjlkdfhalskdjfhalsjkdfhalskdjfhalsdkfjhasldkfjh
School of NetIniciando com PHP
Luiz Carlos
School of Net Iniciando com PHP
School of Net Iniciando com PHP
$string1 $string2
- 01-PHP-Basico\12-precedencias.php
<?php
$soma = 5 + 3 * 8;
$soma = 5 + 24;
$soma = 29;
//esquerda -------> direita
$string = "School of Net" . "Iniciando com PHP";
$string = "School of NetIniciando com PHP";
echo 5 + 3 * 8; // 29
echo "\n";
$soma = (5 + 3 * 5) * 8;
echo "\n";
echo $soma; // 160
- 01-PHP-Basico\13-cometarios.php
<?php
//Está sendo armazenado a soma de 5 com 3 na variável $variavel
//texto
//texto
$variavel = 5 + 3; //explicação
/* School of Net */
/*
School of Net
asdfasdf
asdfasdf
asdfasdf
asdfasdf
asdfasdfsadf
*/
// comentario de uma linha
/* comentario multilinha */
/****************************************************
*
* Texto
*
*
*
****************************************************/
/******* TEXTO *****************/
- 01-PHP-Basico\14-arrays.php
<?php
$array = array(40, 200, 100, 150, "School of Net", true);
//declaração flexível
$array = array(
40,
200,
100,
150,
"School of Net",
true
);
//echo $array;
//echo array(40,200,100,150,"School of Net",true);
echo $array[0] . "\n";
echo $array[1] . "\n";
echo array(40, 200, 100, 150, "School of Net", true)[4] . "\n";
$array1 = [
45,
210,
110,
160,
"School of Ne1111111t",
false
];
$array1[3];
- 01-PHP-Basico\15-arrays-chave-valor.php
<?php
//array chaves - 0 1 2 3 4 5
//array - chaves e valores
$array = array(
'luiz' => 40,
200,
100,
3000 => 150,
"School of Net",
true
);
echo $array['luiz'];
echo "\n";
echo $array[1];
echo "\n";
echo $array[3000];
echo "\n";
//echo $array[2];
//echo "\n";
echo $array[3001];
echo "\n";
var_dump($array);
40
100
150
School of Net
array(6) {
["luiz"]=>
int(40)
[0]=>
int(200)
[1]=>
int(100)
[3000]=>
int(150)
[3001]=>
string(13) "School of Net"
[3002]=>
bool(true)
}
- 01-PHP-Basico\17-php-html.php
<?php
$nome = "José Malcher jr";
$html = "<h1>Iniciando com PHP</h1>";
?>
<html>
<head></head>
<body>
<?php
//echo 5 + 3;
echo $nome;
?>
<?php echo $nome; ?>
<?php echo $html; ?>
</body>
</html>
<?php
//HTTP - GET e POST
var_dump($_GET);
var_dump($_POST);
?>
<h1><?php //echo $_GET['nome']?></h1>
<h1><?php echo $_POST['nome'] ?></h1>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<form action="18-recebe-info.php" method="POST">
<input type="text" name="nome">
<button type="submit">Enviar</button>
</form>
</body>
</html>