aprende PHP leccion 5

in #programacion7 years ago (edited)

Tipos de variables PHP

Los nombres de variables inicia con el signo $ y son sensibles a mayúsculas y minúsculas (no así las palabras claves del lenguaje).
En el lenguaje PHP no es necesario definir el tipo de variable antes de utilizarla, las mismas se crean en el momento de emplearlas. Las variables se declaran cuando se le asigna un valor, por ejemplo:

$dia = 24; //Se declara una variable de tipo integer.
$sueldo = 758.43; //Se declara una variable de tipo double.
$nombre = "juan"; //Se declara una variable de tipo string. 
$exite = true; //Se declara una variable boolean.

También podemos hacer notar que para disponer comentarios de línea debemos utilizar dos caracteres //

Para mostrar las variables en pantalla utilizaremos al inicio el comando echo. Un programa terminado que inicializa y muestra el contenido de cuatro variables de distinto tipo es:

<html>
<head>
<title>Problema </title >
</head>
<body>
<?php
$dia =24; //Se declara una variable de tipo integer.
$sueldo =758.43; //Se declara una variable de tipo double.
$nombre ="juan"; //Se declara una variable de tipo string.
$exite =true; //Se declara una variable boolean.
echo "Variable entera:";
echo $dia;
echo"<br>";
echo"Variable double:";
echo$sueldo;
echo"<br>";
echo"Variable string:";
echo$nombre;
echo"<br>";
echo"Variable boolean:";
echo$exite;
?>
</body>
</html>

Asi debe quedar nuestro codigo en el Notepad++ .

luego de haber iniciado el WampServer y editado el codigo anterior en nuestro Notepad++ y si todo nos quedo bien nos imprimira en pantalla el siguiente resultado en el navegador .

Hemos utilizado un comando echo para mostrar los mensajes, otro el contenido de variables y finalmente otro para imprimir marcas HTML. Este proceso puede acortarse un poco pero para que sea más claro inicialmente tomaremos el camino largo de hacer la impresión de un dato con cada comando echo.

<-Anterior Leccion 4

Sort:  

This post has been ranked within the top 50 most undervalued posts in the second half of Aug 12. We estimate that this post is undervalued by $17.33 as compared to a scenario in which every voter had an equal say.

See the full rankings and details in The Daily Tribune: Aug 12 - Part II. You can also read about some of our methodology, data analysis and technical details in our initial post.

If you are the author and would prefer not to receive these comments, simply reply "Stop" to this comment.

great post, as usual!

Este Post ha recibido un Upvote desde la cuenta del King: @dineroconopcion, El cual es un Grupo de Soporte mantenido por @wilbertphysique, @yoenelmundo y 5 personas mas que quieren ayudarte a llegar hacer un Top Autor En Steemit sin tener que invertir en Steem Power. Te Gustaria Ser Parte De Este Projecto?

This Post has been Upvote from the King's Account: @dineroconopcion, It's a Support Group run by @wilbertphysique, @yoenelmundo, and 5 other people that want to help you be a Top Steemit Author without having to invest into Steem Power. Would You Like To Be Part of this Project?

Congratulations! This post has been upvoted from the communal account, @minnowsupport, by LOGAN6230 from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, theprophet0, someguy123, neoxian, followbtcnews/crimsonclad, and netuoso. The goal is to help Steemit grow by supporting Minnows and creating a social network. Please find us in the Peace, Abundance, and Liberty Network (PALnet) Discord Channel. It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.

This post has received a Bellyrub and 5.99 % upvote from @bellyrub thanks to: @logan6230. Vote @zeartul for witness!

You received an Upvote from @steemthat manually due to the age of your post. Thank you for using @steemthat during it's beta test. Let's try posts that do not say 6 days or 7 days or more days old. Thank you again and know that you can connect with me on twitter also https://twitter.com/steemthat

Coin Marketplace

STEEM 0.20
TRX 0.15
JST 0.030
BTC 64884.95
ETH 2619.31
USDT 1.00
SBD 2.82