PHP. Passing by reference

Home » Tutorials » PHP » PHP. Passing by reference
In this lesson we will discuss value of variables by reference (hard and symbolic links), and data types in php. I will write code in netbeans ide (integrated development environment).
I recommend you to install this application. It s free and easy to install. Before install it you must download and install java (which netbeans uses) – jdk (if you write java code) and jre (for php, ruby and so on).

Code lesson

<?php

/**
 * PHP - язык с динамической типизацией
 * Типы переменных
 * Скалярные
 *     boolean (true/false (TRUE/FALSE));
 *     integer (10,100,-1600);
 *     float (10.4, -5.6);
 *     string ("test");
 * Смешанные
 *      array - ($arr = (1,2,3,4));
 *      object - объект
 * Специальные
 *      resource
 *      null   
 */

$x = 20;
$y = &$c;
/*$x = $x + 2;
$y = $x;
echo "<br>";*/
echo "x ravno $x";
echo "<br>";
echo "y ravno $y";
echo "<br>";

unset($x);
unset($y);
echo "x ravno $x";
echo "<br>";
echo "y ravno $y";
echo "<br>";

$var = "100";
echo gettype($var);
$p = "var";

echo $$p;
echo "<br>";

echo "y ravno $y";
echo "<br>";
echo "c ravno $c";
echo "<br>";

echo gettype($y);
echo gettype($c);
echo "<br>";

echo "$d";

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