image


Valora:  2.5/5
Inicio » PHP » PHP Tutorial » Basic concepts




Variables

A variable is an information container in which we can insert integers, decimals, characters… the content in the variables can be parsed (read) and can be changed while running a PHP page.

In PHP all variables begin with the symbol $ and it is not necessary to define a variable before using it. There are no variable types either; this means that one variable may contain a number and then characters.

<!-- PHP Tutorial WebEstilo.com -->
<html>
<head>
   <title>PHP Example</title>
</head>
<body>
<?php
   $a = 1;
   $b = 3.34;
   $c = "Hello World";
   echo $a,"<br>",$b,"<br>",$c;
?>

</body>
</html>

Execute View code

In this example, we have defined three variables, $a, $b and $c, and with the echo statement, we have printed the value contained in them inserting a line break between them.


There are 2 kinds of variables, local variables that can only be used inside the functions, and global variables that can be used outside the functions. We can access a global variable from a function using the instruction global variable_name;





WebEstilo.com - Introduzca su e-mail y conozca las novedades. No hacemos Spam.
Google
  Web WebEstilo.com   
 
Valid HTML 4.01!
Última modificación:24 de Diciembre de 2004. Spain - España.
© 1998-2004 por Joaquin Gracia. Todos los derechos reservados.