frame

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Register

PHP Data Types

PHP Data Types

PHP string

<!DOCTYPE html>
<html>
<body>


<?php 
$x = "Hello world!";
$y = 'Hello world!';


echo $x;
echo "<br>"; 
echo $y;
?>


</body>
</html>

PHP integer

<!DOCTYPE html>
<html>
<body>


<?php  
$x = 5985;
var_dump($x);
?>  


</body>
</html>

PHP float

<!DOCTYPE html>
<html>
<body>


<?php  
$x = 10.365;
var_dump($x);
?>  


</body>
</html>

PHP array

<!DOCTYPE html>
<html>
<body>


<?php  
$cars = array("Volvo","BMW","Toyota");
var_dump($cars);
?>  


</body>
</html>

PHP object

<!DOCTYPE html>
<html>
<body>


<?php
class Car {
  public $color;
  public $model;
  public function __construct($color, $model) {
    $this->color = $color;
    $this->model = $model;
  }
  public function message() {
    return "My car is a " . $this->color . " " . $this->model . "!";
  }
}


$myCar = new Car("black", "Volvo");
echo $myCar -> message();
echo "<br>";
$myCar = new Car("red", "Toyota");
echo $myCar -> message();
?>


</body>
</html>


PHP NULL value

<!DOCTYPE html>
<html>
<body>


<?php
$x = "Hello world!";
$x = null;
var_dump($x);
?>


</body>
</html>
Tagged:
Sign In or Register to comment.

Developer

| make vanilla clean and light
@ 2016 Your Sitename, All rights reserved. Material Design is a design language developed by Google. Material Design makes more liberal use of grid-based layouts and responsive animations and transitions.
Powered by VanillaForums, Designed by ThemeSteam

Contact us

info@example.com
support@example.com
(800) 3032120

Get In Touch