Академический Документы
Профессиональный Документы
Культура Документы
<html>
<head>
</head>
<body>
<?php
$i = 5;
$n = 1;
do
$n = $n * $i;
$i -= 1;
?>
</body>
</html>
bucle_for
<html>
<head>
</head>
<body>
<?php
?>
</body>
</html>
bucle_foreach
<html>
<head>
</head>
<body>
<?php
$a = array(1, 2, 3, 17);
?>
</body>
</html>
bucle_while
<html>
<head>
</head>
<body>
<?php
$i = 1;
while($i <= 5)
echo $i."<br>";
$i += 1;
}
?>
</body>
</html>
Cadenas
<html>
<head>
</head>
<body>
<?php
// Strlen()
echo "<hr>";
// Explode()
$pieza = "una-dos-tres-cuatro-cinco";
foreach($piezas as $individuales)
echo $individuales."<br>";
echo "<hr>";
// Sprintf()
$num = 5;
$objeto = 'árbol';
echo "<hr>";
// Substr()
echo $cadenaSubstr."<br>";
echo "<hr>";
// Chop()
echo "<pre>";
echo chop($cadenaChop);
echo "<hr>";
// Strpos()
$encontrar = 'mundo';
<strong>$cadenaStrpos</strong>.";
else
echo "<hr>";
// Str_replace()
echo $cadenSTRreplace."<br>";
echo "<hr>";
// Ucfirst()
$cadenaUCfirst = ucfirst($cadenaUCfirst);
echo $cadenaUCfirst."<br>";
echo "<hr>";
// Ucwords()
$cadenaUcwords = ucwords($cadenaUcwords);
echo $cadenaUcwords."<br>";
echo "<hr>";
// Strtolower()
$cadenaStrtolower = strtolower($cadenaStrtolower);
echo $cadenaStrtolower."<br>";
echo "<hr>";
// Strtoupper()
$cadenaStrtoupper = strtoupper($cadenaStrtoupper);
echo $cadenaStrtoupper."<br>";
echo "<hr>";
// Trim()
echo "<pre>";
echo trim($cadenaTrim);
echo "<hr>";
// Md5()
$cadenaMD5 = md5($cadenaMD5);
echo $cadenaMD5."<br>";
echo "<hr>";
// Nl2br()
$cadenaNl2br = "Hola\nmundo\nHTML";
echo "<pre>";
$cadenaNl2br = nl2br($cadenaNl2br);
echo $cadenaNl2br;
echo "<hr>";
?>
</body>
</html>
comentario_1
<html>
<head>
</head>
<body>
<?php
comentario_2
<html>
<head>
</head>
<body>
<?php
Comentario 3
<html>
<head>
</head>
<body>
<?php
Concatenación
<html>
<head>
</head>
<body>
<?php
$ciudad = "Bogotá";
$pais = "Colombia";
$edad = "30";
?>
</body>
</html>
cuarto_ejemplo_funcion
<html>
<head>
</head>
<body>
<?php
function sumarDatos($dato1,$dato2,$dato3,$item)
$totalDeDatos = $dato1+$dato2+$dato3;
sumarDatos(10,20,1,'Dulces de caramelo');
?>
</body>
</html>
ejemplo_condicional_if
<html>
<head>
</head>
<body>
<h2>Ejemplo de condicionales</h2>
<?php
$a = 15;
// Equivale a Si $a es igual a 15
if ($a == 15)
?>
</body>
</html>
ejemplo_condicional_if_else
<html>
<head>
</head>
<body>
<h2>Ejemplo de condicionales</h2>
<?php
$a = 15;
else
?>
</body>
</html>
ejemplo_condicional_if_elseif_else
<html>
<head>
</head>
<body>
<h2>Ejemplo de condicionales</h2>
<?php
$a = 15;
if ($a == 13)
else
?>
</body>
</html>
ejemplo_get
<html>
<head>
</head>
<body>
<?php
if($_GET)
echo "<pre>";
print_r($_GET);
?>
<p>
<p>
</p>
<p>
<select name="anoNacimiento">
<?php
$anos = 1900;
?>
<option value="<?=$anos;?>"><?=$anos;?></option>
<?php
$anos++;
?>
</select>
</p>
<p>
</p>
</form>
</body>
</html>
ejemplo_post
<html>
<head>
</head>
<body>
<?php
if($_GET)
echo "<pre>";
print_r($_GET);
?>
<p>
<p>
<html>
<head>
</head>
<body>
<?php
if($_POST)
echo "<pre>";
print_r($_POST);
http://tutorialphp.net/iniciacion-a-php-7/introduccion-a-php-7/
?>
<p>
</p>
<p>
</p>
<p>
<select name="anoNacimiento">
<?php
$anos = 1900;
{
?>
<option value="<?=$anos;?>"><?=$anos;?></option>
<?php
$anos++;
?>
</select>
</p>
<p>
http://tutorialphp.net/iniciacion-a-php-7/introduccion-a-php-7/
</p>
</form>
</body>
</html>
ejemplo_switch
<html>
<head>
<title>Ejemplo de condicionales en PHP 7</title>
</head>
<body>
<h2>Ejemplo de condicionales</h2>
<?php
$a = 5;
switch ($a)
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
default:
?>
</body>
</html>
Hola
hola_bucle
<html>
<head>
</head>
<body>
<?php
?>
</body>
</html>
operadores_aritmeticos
<html>
<head>
<body>
<?php
$a = 8;
$b = 3;
echo $a + $b."<br>";
echo $a - $b."<br>";
echo $a * $b."<br>";
echo $a / $b."<br>";
echo $a % $b,"<br>";
$a++;
echo $a."<br>";
$b--;
echo $b."<br>";
?>
</body>
</html>
primer_ejemplo_funcion
<html>
<head>
</head>
<body>
<?php
function saludame()
// Invocamos la función
saludame();
?>
</body>
</html>
salida_printf
<html>
<head>
<title>Ejemplo de printf en PHP 7</title>
</head>
<body>
<?php
%.2f",2,2,2);
?>
</body>
</html>
salida_printf_2
<html>
<head>
</head>
<body>
<?php
$var = "texto";
$num = 3;
printf("Puede fácimente intercalar <b>%s</b> con números
<b>%d</b> <br>",$var,$num);
printf("<tr><td>%10.d</td></tr>",$i);
printf("</table>");
?>
</body>
</html>
segundo_ejemplo_funcion
<html>
<head>
</head>
<body>
<?php
function validarEdad()
$edad = 23;
if($edad == 23)
return true;
else
return false;
if(validarEdad())
?>
</body>
</html>
tercer_ejemplo_funcion
<html>
<head>
</head>
<body>
<?php
function sumarDatos($dato1,$dato2,$dato3,$item)
$totalDeDatos = $dato1+$dato2+$dato3;
".$item.".";
http://tutorialphp.net/iniciacion-a-php-7/introduccion-a-php-7/
sumarDatos(10,20,1,'Dulces de caramelo');
?>
</body>
</html>
Variables
<html>
<head>
</head>
<body>
<?php
$a = 1;
$b = "3.34";
echo $a."<br>".$b."<br>".$c;
?>
</body>
</html>
variables_array
<html>
<head>
</head>
<body>
<?php
$nuestraVariable = array();
http://tutorialphp.net/iniciacion-a-php-7/introduccion-a-php-7/
// Asignemos valores
// Recorramos la matriz
?>
</body>
</html>
variables_cookie
<?php
setcookie("Valor_1", "1");
setcookie("Valor_2", "2");
setcookie("Valor_3", "3");
?>
<html>
<head>
</head>
<body>
<pre>
<?php
print_r($_COOKIE);
?>
</pre >
</body>
</html>
variables_file
<html>
<head>
</head>
<body>
</form>
<pre>
<?php
if($_FILES)
print_r($_FILES);
?>
</pre >
</body>
</html>
variables_funcion
<html>
<head>
</head>
<body>
<?php
$a = 1;
$b = "3.34";
$c = "Contenedor de código PHP 7 en una función.";
function ejemploVariables()
http://tutorialphp.net/iniciacion-a-php-7/introduccion-a-php-7/
echo $a."<br>".$b."<br>".$c;
// Ejecutamos la función
ejemploVariables();
?>
</body>
</html>
variables_get
<html>
<head>
</head>
<body>
<pre>
<?php
print_r($_GET);
?>
</pre >
</body>
</html>
variables_post
</head> <body> <h2>Ejemplo de variables con protocolo POST</h2> <form method="post"> Escribe tu
nombre: <input type="text" name="nombre" value="<?=@$_POST['nombre'];?>"> <br> <br> Escribe tu edad: <input
type="text" name="edad" value="<?=@$_POST['edad'];?>"> <br> <br> <input type="submit" value="Enviar">
</form> <pre> <?php if($_POST) { print_r($_POST); } ?> </pre > </body> </html>
variables_request
<html>
<head>
</head>
<body>
<pre>
<?php
print_r($_REQUEST);
?>
</pre >
</body>
</html>
variables_server
<html>
<head>
</head>
<body>
<pre>
<?php
print_r($_SERVER);
?>
</pre >
</body>
</html>
variables_session
<html>
<head>
</head>
<body>
<pre>
<?php
print_r($_REQUEST);
?>
</pre >
</body>
</html>