• Home
  • Html
  • CSS
  • Angular
  • Aws Cloud
  • Java
  • JavaScript
  • PHP
  • React
  • SQL
  • WordPress
  • Source Code
  • Bulk Qr Code Generator
  • Home
  • Html
  • CSS
  • Angular
  • Aws Cloud
  • Java
  • JavaScript
  • PHP
  • React
  • SQL
  • WordPress
  • Source Code
  • Bulk Qr Code Generator
  • PHP
    • PHP Introduction
    • Install PHP
    • PHP - Syntax
    • PHP Variables and Types
    • PHP String
    • PHP Constants
    • PHP Loop
    • PHP Function
    • PHP Arrays

PHP Variables and Types

9 views 0

PHP Variables and Types 

 Variables in a program are used to store some values or data that can be used later in a program. The variables are also like containers that store character values, numeric values, memory addresses, and strings. PHP has its own way of declaring and storing variables.

  • As PHP is a loosely typed language, so we do not need to declare the data types of the variables. It automatically analyzes the values and makes conversions to its correct datatype.
  • After declaring a variable, it can be reused throughout the code.
  • Assignment Operator (=) is used to assign the value to a variable.

To define a variable, simply use the following syntax:

$x = 1;
$y = "foo";
$z = True;

PHP Variable: Declaring string, integer, and float

Let’s see the example to store string, integer, and float values in PHP variables.

<?php  
$str="hello string";  
$x=200;  
$y=44.6;  
echo "string is: $str <br/>";  
echo "integer is: $x <br/>";  
echo "float is: $y <br/>";  
?>

PHP supports the following data types:

  • String
  • Integer
  • Float (floating point numbers – also called double)
  • Boolean
  • Array
  • Object
  • NULL
  • Resource
Tags:PHPPHP tutorialPHP Variables and Types

Didn't find your answer? Contact Us

Previously
PHP – Syntax
Up Next
PHP String

Didn't Find an Answer?

Get in touch with us for details on setup and additional custom services pricing

Contact Us

    Copyright 2025 interntpoint. All Rights Reserved
    Popular Search:Getting Started