{"id":228,"date":"2024-03-04T18:11:55","date_gmt":"2024-03-04T18:11:55","guid":{"rendered":"https:\/\/www.xopsschool.com\/tutorials\/?p=228"},"modified":"2024-03-05T18:27:56","modified_gmt":"2024-03-05T18:27:56","slug":"php-data-types","status":"publish","type":"post","link":"https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/","title":{"rendered":"PHP Data Types ?"},"content":{"rendered":"\n<p>Data Types define the type of data a variable can store. PHP allows eight different types of data types. All of them are discussed below. There are pre-defined, user-defined, and special data types. PHP automatically determines the data type based on the assigned value. Here are the main data types in PHP.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"364\" height=\"224\" src=\"https:\/\/www.xopsschool.com\/tutorials\/wp-content\/uploads\/2024\/03\/rrrrr.png\" alt=\"\" class=\"wp-image-242\" style=\"width:813px;height:auto\" srcset=\"https:\/\/www.xopsschool.com\/tutorials\/wp-content\/uploads\/2024\/03\/rrrrr.png 364w, https:\/\/www.xopsschool.com\/tutorials\/wp-content\/uploads\/2024\/03\/rrrrr-300x185.png 300w\" sizes=\"auto, (max-width: 364px) 100vw, 364px\" \/><\/figure>\n\n\n\n<p><strong>The Scalar data types are:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li> Integer<\/li>\n\n\n\n<li>Boolean   <\/li>\n\n\n\n<li>Double<\/li>\n\n\n\n<li>String<\/li>\n<\/ul>\n\n\n\n<p><strong>The user-defined (compound) data types are<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Array<\/li>\n\n\n\n<li>Objects<\/li>\n<\/ul>\n\n\n\n<p><strong>The special data types are<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>NULL<\/li>\n\n\n\n<li>resource<\/li>\n<\/ul>\n\n\n\n<p><strong> Integer<\/strong> :<\/p>\n\n\n\n<p>Integers are whole numbers, without a decimal point (\u2026, -2, -1, 0, 1, 2, \u2026). Integers can be specified in decimal (base 10), hexadecimal (base 16 &#8211; prefixed with 0x) or octal (base 8 &#8211; prefixed with 0) notation, optionally preceded by a sign (- or +).<\/p>\n\n\n\n<p><strong>Example :-<\/strong><br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html lang=\"en\"&gt;\n&lt;head&gt;\n    &lt;title&gt; Integers&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n\n&lt;?php\n$a = 123; \/\/ decimal number\nvar_dump($a);\necho \"&lt;br&gt;\";\n \n$b = -123; \/\/ a negative number\nvar_dump($b);\necho \"&lt;br&gt;\";\n \n$c = 0x1A; \/\/ hexadecimal number\nvar_dump($c);\necho \"&lt;br&gt;\";\n \n$d = 0123; \/\/ octal number\nvar_dump($d);\n?&gt;\n\n&lt;\/body&gt;\n&lt;\/html&gt;\n\n<strong>output:-<\/strong>\nint(123)\nint(-123)\nint(26)\nint(83)\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">PHP Booleans<\/h3>\n\n\n\n<p>Booleans are like a switch it has only two possible values either 1 (true) or 0 (false).<\/p>\n\n\n\n<p><strong>Example<\/strong> <strong>:-<\/strong> <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html lang=\"en\"&gt;\n&lt;head&gt;\n    &lt;title&gt;PHP Booleans&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n\n&lt;?php\n\/\/ Assign the value TRUE to a variable\n$show_error = True;\nvar_dump($show_error);\n?&gt;\n\n&lt;\/body&gt;\n&lt;\/html&gt;\n\n<strong>Output:-<\/strong>\n\nbool(true)\n<\/code><\/pre>\n\n\n\n<p><strong>PHP Floating Point Numbers or Double<\/strong><\/p>\n\n\n\n<p>Represent real numbers with a fractional part. They are used to handle values with decimal points and provide a wide range of precision.<\/p>\n\n\n\n<p><br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> &lt;!DOCTYPE html&gt;\n&lt;html lang=\"en\"&gt;\n&lt;head&gt;\n    &lt;meta charset=\"UTF-8\"&gt;\n    &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"&gt;\n    &lt;title&gt;PHP Floats&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n\n&lt;div&gt;\n    &lt;h1&gt;PHP Floats &lt;\/h1&gt;\n\n    &lt;?php\n    \/\/ Floating-point number examples\n    $a = 1.234;\n    $b = 10.2e3; \/\/ 10.2 multiplied by 10^3 (10 to the power of 3)\n    $c = 4E-10;  \/\/ 4 multiplied by 10^-10 (10 to the power of -10)\n\n    \/\/ Output the variable values and types\n    echo \"&lt;p&gt;Value of \\$a: $a, Type: \" . gettype($a) . \"&lt;\/p&gt;\";\n    echo \"&lt;p&gt;Value of \\$b: $b, Type: \" . gettype($b) . \"&lt;\/p&gt;\";\n    echo \"&lt;p&gt;Value of \\$c: $c, Type: \" . gettype($c) . \"&lt;\/p&gt;\";\n    ?&gt;\n&lt;\/div&gt;\n\n&lt;footer&gt;\n    &lt;p&gt;PHP Floats Example - &amp;copy; 2024 Your Company&lt;\/p&gt;\n&lt;\/footer&gt;\n\n&lt;\/body&gt;\n&lt;\/html&gt;\n\nOutput :-<\/code><\/pre>\n\n\n\n<p>PHP Floats<br>Value of $a: 1.234, Type: double<\/p>\n\n\n\n<p>Value of $b: 10200, Type: double<\/p>\n\n\n\n<p>Value of $c: 4.0E-10, Type: double<\/p>\n\n\n\n<p><strong>String<\/strong><\/p>\n\n\n\n<p>PHP, strings are used to represent sequences of characters. They can contain letters, numbers, symbols, and spaces. PHP provides various functions and features for manipulating and working with strings.<\/p>\n\n\n\n<p>Example <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  &lt;!DOCTYPE html&gt;\n&lt;html lang=\"en\"&gt;\n&lt;head&gt;\n    &lt;title&gt;PHP Strings&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n\n&lt;?php\n$a = 'Hello Ritik!';\n\necho $a;\n?&gt;\n\n&lt;\/body&gt;\n&lt;\/html&gt;\n\n<strong>Output :-<\/strong>\n\nHello Ritik!<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Data Types define the type of data a variable can store. PHP allows eight different types of data types. All of them are discussed below. There are pre-defined, user-defined, and special data types. PHP automatically determines the data type based on the assigned value. Here are the main data types in PHP. The Scalar data &#8230; <a title=\"PHP Data Types ?\" class=\"read-more\" href=\"https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/\" aria-label=\"Read more about PHP Data Types ?\">Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-228","post","type-post","status-publish","format-standard","hentry","category-basic-php-syntax"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PHP Data Types ? - XOps Tutorials!!!<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PHP Data Types ? - XOps Tutorials!!!\" \/>\n<meta property=\"og:description\" content=\"Data Types define the type of data a variable can store. PHP allows eight different types of data types. All of them are discussed below. There are pre-defined, user-defined, and special data types. PHP automatically determines the data type based on the assigned value. Here are the main data types in PHP. The Scalar data ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/\" \/>\n<meta property=\"og:site_name\" content=\"XOps Tutorials!!!\" \/>\n<meta property=\"article:published_time\" content=\"2024-03-04T18:11:55+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-05T18:27:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.xopsschool.com\/tutorials\/wp-content\/uploads\/2024\/03\/rrrrr.png\" \/>\n<meta name=\"author\" content=\"ritik hansda\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"ritik hansda\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/\"},\"author\":{\"name\":\"ritik hansda\",\"@id\":\"https:\/\/www.xopsschool.com\/tutorials\/#\/schema\/person\/c0119ddd2d27ea9cd476e809c8294ba7\"},\"headline\":\"PHP Data Types ?\",\"datePublished\":\"2024-03-04T18:11:55+00:00\",\"dateModified\":\"2024-03-05T18:27:56+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/\"},\"wordCount\":215,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.xopsschool.com\/tutorials\/wp-content\/uploads\/2024\/03\/rrrrr.png\",\"articleSection\":[\"Basic PHP Syntax\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/\",\"url\":\"https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/\",\"name\":\"PHP Data Types ? - XOps Tutorials!!!\",\"isPartOf\":{\"@id\":\"https:\/\/www.xopsschool.com\/tutorials\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.xopsschool.com\/tutorials\/wp-content\/uploads\/2024\/03\/rrrrr.png\",\"datePublished\":\"2024-03-04T18:11:55+00:00\",\"dateModified\":\"2024-03-05T18:27:56+00:00\",\"author\":{\"@id\":\"https:\/\/www.xopsschool.com\/tutorials\/#\/schema\/person\/c0119ddd2d27ea9cd476e809c8294ba7\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/#primaryimage\",\"url\":\"https:\/\/www.xopsschool.com\/tutorials\/wp-content\/uploads\/2024\/03\/rrrrr.png\",\"contentUrl\":\"https:\/\/www.xopsschool.com\/tutorials\/wp-content\/uploads\/2024\/03\/rrrrr.png\",\"width\":364,\"height\":224},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.xopsschool.com\/tutorials\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PHP Data Types ?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.xopsschool.com\/tutorials\/#website\",\"url\":\"https:\/\/www.xopsschool.com\/tutorials\/\",\"name\":\"XOps Tutorials!!!\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.xopsschool.com\/tutorials\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.xopsschool.com\/tutorials\/#\/schema\/person\/c0119ddd2d27ea9cd476e809c8294ba7\",\"name\":\"ritik hansda\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.xopsschool.com\/tutorials\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6fe0bc437410899c524975272622377e50e726108b1ad03f7b4488f734304fce?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6fe0bc437410899c524975272622377e50e726108b1ad03f7b4488f734304fce?s=96&d=mm&r=g\",\"caption\":\"ritik hansda\"},\"url\":\"https:\/\/www.xopsschool.com\/tutorials\/author\/ritikhansda\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PHP Data Types ? - XOps Tutorials!!!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/","og_locale":"en_US","og_type":"article","og_title":"PHP Data Types ? - XOps Tutorials!!!","og_description":"Data Types define the type of data a variable can store. PHP allows eight different types of data types. All of them are discussed below. There are pre-defined, user-defined, and special data types. PHP automatically determines the data type based on the assigned value. Here are the main data types in PHP. The Scalar data ... Read more","og_url":"https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/","og_site_name":"XOps Tutorials!!!","article_published_time":"2024-03-04T18:11:55+00:00","article_modified_time":"2024-03-05T18:27:56+00:00","og_image":[{"url":"https:\/\/www.xopsschool.com\/tutorials\/wp-content\/uploads\/2024\/03\/rrrrr.png","type":"","width":"","height":""}],"author":"ritik hansda","twitter_card":"summary_large_image","twitter_misc":{"Written by":"ritik hansda","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/#article","isPartOf":{"@id":"https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/"},"author":{"name":"ritik hansda","@id":"https:\/\/www.xopsschool.com\/tutorials\/#\/schema\/person\/c0119ddd2d27ea9cd476e809c8294ba7"},"headline":"PHP Data Types ?","datePublished":"2024-03-04T18:11:55+00:00","dateModified":"2024-03-05T18:27:56+00:00","mainEntityOfPage":{"@id":"https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/"},"wordCount":215,"commentCount":0,"image":{"@id":"https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/#primaryimage"},"thumbnailUrl":"https:\/\/www.xopsschool.com\/tutorials\/wp-content\/uploads\/2024\/03\/rrrrr.png","articleSection":["Basic PHP Syntax"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/","url":"https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/","name":"PHP Data Types ? - XOps Tutorials!!!","isPartOf":{"@id":"https:\/\/www.xopsschool.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/#primaryimage"},"image":{"@id":"https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/#primaryimage"},"thumbnailUrl":"https:\/\/www.xopsschool.com\/tutorials\/wp-content\/uploads\/2024\/03\/rrrrr.png","datePublished":"2024-03-04T18:11:55+00:00","dateModified":"2024-03-05T18:27:56+00:00","author":{"@id":"https:\/\/www.xopsschool.com\/tutorials\/#\/schema\/person\/c0119ddd2d27ea9cd476e809c8294ba7"},"breadcrumb":{"@id":"https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/#primaryimage","url":"https:\/\/www.xopsschool.com\/tutorials\/wp-content\/uploads\/2024\/03\/rrrrr.png","contentUrl":"https:\/\/www.xopsschool.com\/tutorials\/wp-content\/uploads\/2024\/03\/rrrrr.png","width":364,"height":224},{"@type":"BreadcrumbList","@id":"https:\/\/www.xopsschool.com\/tutorials\/php-data-types\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.xopsschool.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"PHP Data Types ?"}]},{"@type":"WebSite","@id":"https:\/\/www.xopsschool.com\/tutorials\/#website","url":"https:\/\/www.xopsschool.com\/tutorials\/","name":"XOps Tutorials!!!","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.xopsschool.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.xopsschool.com\/tutorials\/#\/schema\/person\/c0119ddd2d27ea9cd476e809c8294ba7","name":"ritik hansda","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.xopsschool.com\/tutorials\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6fe0bc437410899c524975272622377e50e726108b1ad03f7b4488f734304fce?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6fe0bc437410899c524975272622377e50e726108b1ad03f7b4488f734304fce?s=96&d=mm&r=g","caption":"ritik hansda"},"url":"https:\/\/www.xopsschool.com\/tutorials\/author\/ritikhansda\/"}]}},"_links":{"self":[{"href":"https:\/\/www.xopsschool.com\/tutorials\/wp-json\/wp\/v2\/posts\/228","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xopsschool.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xopsschool.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xopsschool.com\/tutorials\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xopsschool.com\/tutorials\/wp-json\/wp\/v2\/comments?post=228"}],"version-history":[{"count":4,"href":"https:\/\/www.xopsschool.com\/tutorials\/wp-json\/wp\/v2\/posts\/228\/revisions"}],"predecessor-version":[{"id":244,"href":"https:\/\/www.xopsschool.com\/tutorials\/wp-json\/wp\/v2\/posts\/228\/revisions\/244"}],"wp:attachment":[{"href":"https:\/\/www.xopsschool.com\/tutorials\/wp-json\/wp\/v2\/media?parent=228"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xopsschool.com\/tutorials\/wp-json\/wp\/v2\/categories?post=228"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xopsschool.com\/tutorials\/wp-json\/wp\/v2\/tags?post=228"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}