PHP String

Rumman Ansari   Software Engineer   2022-11-02   5624 Share
☰ Table of Contents

Table of Content:


PHP data types are used to hold different types of data or values. PHP supports the following data types:

  • String
  • Integer
  • Float
  • Boolean
  • Array
  • Object
  • NULL
  • Resource

PHP String

A string is a sequence of characters, like "Hello world!".

A string can be any text inside quotes. You can use single or double quotes:

Example code:


<?php

$x = "Hello world!";
$y = 'Hello world!';

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

?>


Output:

The above code will produce the following result-


Hello world!
Hello world!

PHP Resource

The special resource type is not an actual data type. It is the storing of a reference to functions and resources external to PHP.

A common example of using the resource data type is a database call.

We will talk about the resource type in advanced topic.