PHP. Hosting. Variables. Print data.

Home » Tutorials » PHP » PHP. Hosting. Variables. Print data.
In last lesson we began learning php. In this lesson we’ll talk about variables, how to declare variables in php. But first of all I’ll talk about hosting. Hosting is the service of getting you the place in the server. Modern hosting services includes availability of databases, email, FTP and so on. Also there are free hosting services. The main advantage is free. The main flaw is resource constraint and impossibility to register your own domain name
As for php, namely variables: variables must begin from dollar symbol. Name of the variable must begin from letter or underscore. Variables in php are case-sensitive. $var and $Var are different variables.
PHP has got two ways to print data:

  • echo construction.
  • print function.

More often echo uses. Example:

echo example

echo "1";
echo '1';
The result is the same. What are the differences? Consider an example:

echo differences

$var = "str";
echo "$var"; // выведет str
echo '$var'; //выведет $var
While print variable in quotes its value will be printed. If single quotes, original text will be printed.

Code lesson

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	
<?php

$var = 1;
$varOne = 2;

echo $var . $varOne;  


print($var); 



?>


</body>
</html>

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

Pin It on Pinterest

Share This