{"id":77195,"date":"2022-09-15T05:58:19","date_gmt":"2022-09-15T05:58:19","guid":{"rendered":"https:\/\/itsourcecode.com\/?p=77195"},"modified":"2023-10-26T07:27:42","modified_gmt":"2023-10-26T07:27:42","slug":"php-basic-syntax-and-comments-overview-with-examples","status":"publish","type":"post","link":"https:\/\/itsourcecode.com\/php-tutorial\/php-basic-syntax-and-comments-overview-with-examples\/","title":{"rendered":"PHP Basic Syntax and Comments Overview (With Examples)"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"h-what-is-basic-php-syntax\"><strong>What is basic PHP syntax?<\/strong><\/h2>\n\n\n\n<p>Basic PHP syntax is the set of rules that make up the structure of the PHP computer language.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>PHP<\/strong>, which stands for <strong>Hypertext Preprocessor<\/strong>, is a popular, open-source, general-purpose scripting language that can be used with HTML. The <code><mark style=\"background-color:var(--base-3);color:#ff0000\" class=\"has-inline-color\">.php<\/mark><\/code> extension is used to save files that use PHP.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>There are four ways that the parser can tell where PHP code starts and stops:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>PHP Canonical Tags<\/strong><\/li>\n\n\n\n<li><strong>SGML-style (Short-open) tags<\/strong><\/li>\n\n\n\n<li><strong>ASP Style tags<\/strong><\/li>\n\n\n\n<li><strong>HTML script tags<\/strong><\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-php-canonical-tags\"><strong>PHP Canonical Tags<\/strong><\/h3>\n\n\n\n<p class=\"tw-highlight-padding\">The canonical opening tag of the PHP script is <code><mark style=\"background-color:var(--base-3);color:#ff0000\" class=\"has-inline-color\">&lt;?php<\/mark><\/code> and the closing tag is <mark style=\"background-color:var(--base-3);color:#ff0000\" class=\"has-inline-color\"><code>?><\/code><\/mark>.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Additional information from <a href=\"https:\/\/www.php.net\/manual\/en\/language.basic-syntax.phptags.php#language.basic-syntax.phptags\">PHP Official Documentation<\/a>, when PHP parses a file, it looks for opening and closing tags, which are&nbsp;&lt;?php&nbsp;and&nbsp;?&gt;&nbsp;which tells PHP to start and stop interpreting the code between them.&nbsp;<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/09\/Php-Basic-Syntax-Opening-and-Closing-Tags-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"400\" src=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/09\/Php-Basic-Syntax-Opening-and-Closing-Tags-1.png\" alt=\"Php-Basic-Syntax-Opening-and-Closing-Tags\" class=\"wp-image-77211\" srcset=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/09\/Php-Basic-Syntax-Opening-and-Closing-Tags-1.png 1000w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/09\/Php-Basic-Syntax-Opening-and-Closing-Tags-1-300x120.png 300w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/09\/Php-Basic-Syntax-Opening-and-Closing-Tags-1-768x307.png 768w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/a><\/figure><\/div>\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-example\"><strong>Example:<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>&lt;?php\n# This function is used to print\necho \"Welcome to PHP Tutorial!\"\n?&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted tw-rounded\"><code>Welcome to PHP Tutorial!<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-php-sgml-style-short-open-tags\"><strong>PHP SGML-Style (Short Open) Tags<\/strong><\/h3>\n\n\n\n<p class=\"tw-highlight-padding\">These tags are the shortest and easiest way to represent PHP code. The opening tag of SGML-Style is <code><mark style=\"background-color:var(--base-3);color:#ff0000\" class=\"has-inline-color\">&lt;?php<\/mark><\/code> and the closing tag is <mark style=\"background-color:var(--base-3);color:#ff0000\" class=\"has-inline-color\"><code>?&gt;<\/code><\/mark>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/09\/PHP-SGML-Style-Short-Open-Tags.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"400\" src=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/09\/PHP-SGML-Style-Short-Open-Tags.png\" alt=\"PHP SGML-Style (Short Open) Tags\" class=\"wp-image-77213\" srcset=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/09\/PHP-SGML-Style-Short-Open-Tags.png 1000w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/09\/PHP-SGML-Style-Short-Open-Tags-300x120.png 300w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/09\/PHP-SGML-Style-Short-Open-Tags-768x307.png 768w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/a><\/figure><\/div>\n\n\n<p><\/p>\n\n\n\n<p>However the SGML-styled tags are harder to set up than the canonical option, which is almost a standard.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>As you might expect, short tags are the shortest choice. To make PHP recognize the tags, you must do one of two things.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>When setting up PHP, choose the <code><mark style=\"background-color:var(--base-3);color:#ff0000\" class=\"has-inline-color\">enable-short-tags<\/mark><\/code> configuration option.<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>In your <code><mark style=\"background-color:var(--base-3);color:#ff0000\" class=\"has-inline-color\">php.ini<\/mark><\/code> file, turn on the setting for a short open tag. To parse XML with PHP, this option must be turned off because XML tags use the same syntax.<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-example-0\"><strong>Example:<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>&lt;?\n# This function is used to print\necho \"Welcome to PHP Tutorial!\"\n?&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted tw-rounded\"><code>Welcome to PHP Tutorial!<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-php-asp-style-tags\"><strong>PHP ASP Style Tags<\/strong><\/h3>\n\n\n\n<p>ASP-style tags look like the tags that are used to separate code blocks in Active Server Pages. Different parts of the code are marked with signs. Here&#8217;s how they are used in PHP:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/09\/PHP-ASP-Style-Tags.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"400\" src=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/09\/PHP-ASP-Style-Tags.png\" alt=\"PHP ASP Style Tags\" class=\"wp-image-77218\" srcset=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/09\/PHP-ASP-Style-Tags.png 1000w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/09\/PHP-ASP-Style-Tags-300x120.png 300w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/09\/PHP-ASP-Style-Tags-768x307.png 768w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/a><\/figure><\/div>\n\n\n<p><\/p>\n\n\n\n<p class=\"tw-highlight-padding\">For this code block to work, we need to change the <code><mark style=\"background-color:var(--base-3);color:#ff0000\" class=\"has-inline-color\">php.ini<\/mark><\/code> file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>&lt;%\n# This asp tag can be used if you allow php.ini to use %\necho \"Welcome to PHP Tutorial!\"\n%&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted tw-rounded\"><code>Welcome to PHP Tutorial!<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-php-html-script-tags\"><strong>PHP HTML Script Tags<\/strong><\/h3>\n\n\n\n<p>They are commonly used by web programmers and developers, especially when putting in scripts from other files like <em>JavaScript <\/em>or <em>CSS<\/em>. HTML is the first thing most people who build websites learn.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>But in the most recent version of PHP 7, this option was taken away, so you can no longer use it.<\/p>\n\n\n\n<p>This is how HTML script tags look:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/09\/PHP-HTML-Script-Tags.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"400\" src=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/09\/PHP-HTML-Script-Tags.png\" alt=\"PHP HTML Script Tags\" class=\"wp-image-77219\" srcset=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/09\/PHP-HTML-Script-Tags.png 1000w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/09\/PHP-HTML-Script-Tags-300x120.png 300w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/09\/PHP-HTML-Script-Tags-768x307.png 768w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/a><\/figure><\/div>\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-example-1\"><strong>Example:<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>&lt;script language=\"php\"&gt; \n# This echo is used to print\necho \"Welcome to PHP Tutorial!\"\n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted tw-rounded\"><code>Welcome to PHP Tutorial!<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-contrast-3-color has-alpha-channel-opacity has-contrast-3-background-color has-background is-style-wide\"\/>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-case-sensitivity-in-php\"><strong>Case Sensitivity in PHP<\/strong><\/h2>\n\n\n\n<p>Below explains the case sensitivity of PHP:<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-php-is-insensitive-to-whitespace\"><strong>PHP is insensitive to whitespace<\/strong><\/h3>\n\n\n\n<p>This includes <em>tabs<\/em>, <em>spaces<\/em>, and <em>carriage returns<\/em>, which are <strong>not visible<\/strong> on the screen. One space is the same as any number of spaces or carriage returns.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>This means that PHP will ignore any spaces, tabs, carriage returns, or carriage returns in more than one row. If PHP doesn&#8217;t see a semicolon, it thinks of multiple lines as a single command.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-example-2\"><strong>Example:<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>&lt;?php\n$x =\n50;\n$y =\t45;\n$add =     $x\n+\n$y;\n\n\/\/ This code below prints the sum of x and y variables\necho $add.\"\\n\";\n\n\/\/ This code below is the same as the code above but without spaces\n$add1 = $x + $y;\necho $add1;\n?&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted tw-rounded\"><code>95\n95<\/code><\/pre>\n\n\n\n<p>Both of them give the same, correct results.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-php-is-case-sensitive\"><strong>PHP is case-sensitive<\/strong><\/h3>\n\n\n\n<p class=\"tw-highlight-padding\">Except for variables, all PHP <em>keywords<\/em>, <em>functions<\/em>, and <em>class names<\/em> (<code><mark style=\"background-color:var(--base-3);color:#ff0000\" class=\"has-inline-color\">while<\/mark><\/code>, <code><mark style=\"background-color:var(--base-3);color:#ff0000\" class=\"has-inline-color\">if<\/mark><\/code>, <code><mark style=\"background-color:var(--base-3);color:#ff0000\" class=\"has-inline-color\">echo<\/mark><\/code>, <code><mark style=\"background-color:var(--base-3);color:#ff0000\" class=\"has-inline-color\">else<\/mark><\/code>, etc.) are <strong>case-insensitive<\/strong>. Only variables that have different cases get different treatments.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Let&#8217;s take a look at this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>&lt;?php\n\/\/ The code below is executed the same but in different cases of echo\n  \n$var = \"Hello PHP!\";\necho $var.\"\\n\";\nECHO $var.\"\\n\";\nEcHo $var.\"\\n\";\n \n\/\/ The code below prompts an error called\n\/\/ \"Undefined Variable\" because of the case sensitivity to variable\necho $VAR\n?&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Output:\u00a0<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted tw-rounded\"><code>Hello PHP!\nHello PHP!\nHello PHP!\n\n<em>PHP Notice:  Undefined variable: VAR in HelloPhp.php on line 11<\/em><\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-contrast-3-color has-alpha-channel-opacity has-contrast-3-background-color has-background is-style-wide\"\/>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-comments-in-php\"><strong>Comments in PHP<\/strong><\/h2>\n\n\n\n<p>When the code is reviewed again after a while, comments help the developer remember what it does.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>The purpose of a comment is to make the code easier to read\u00a0and understand. These are utilized to assist other users and developers in describing the code and its purpose.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>It may also be used to document a collection of codes or program components. Surely you saw this in the preceding sample applications.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>PHP supports two types of comments:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Single Line Comment<\/strong><\/li>\n\n\n\n<li><strong>Multi-Line or Multiple Line Comment<\/strong><\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-single-line-comment\"><strong>Single Line Comment<\/strong><\/h3>\n\n\n\n<p class=\"tw-highlight-padding\">As the name implies, these are single lines or brief relevant explanations that can be added to one&#8217;s code. To include this, start the line with (<code><mark style=\"background-color:var(--base-3);color:#ff0000\" class=\"has-inline-color\">\/\/<\/mark><\/code>) or (<code><mark style=\"background-color:var(--base-3);color:#ff0000\" class=\"has-inline-color\">#<\/mark><\/code>).<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-example-3\"><strong>Example:<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>&lt;?php\n\/\/ This is a single line comment\n\/\/ These cannot be extended to more lines\n\necho \"PHP Single Line Comment\"; \/\/ This is a comment also\n \n# This is also a single line comment\n?&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted tw-rounded\"><code>PHP Single Line Comment\n<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-multi-line-or-multiple-line-comment\"><strong>Multi-line or Multiple line Comment<\/strong><\/h3>\n\n\n\n<p class=\"tw-highlight-padding\">These are used to allow several lines with a single tag and can be expanded to the number of lines desired by the user. <\/p>\n\n\n\n<p>The line must begin with (<code><mark style=\"background-color:var(--base-3);color:#ff0000\" class=\"has-inline-color\">\/*<\/mark><\/code>) and ends with (<code><mark style=\"background-color:var(--base-3);color:#ff0000\" class=\"has-inline-color\">*\/<\/mark><\/code>) to accommodate this addition.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>See the example below:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>&lt;?php\n\/*\nThis is a multi line comment\nYou can use this to comment a code or describe a code\n*\/<\/code>\n<code>\necho \"PHP Multiple Line Comment\";\n?&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Output<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted tw-rounded\"><code>PHP Multiple Line Comment<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-contrast-3-color has-alpha-channel-opacity has-contrast-3-background-color has-background is-style-wide\"\/>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-php-blocks\"><strong>PHP &#8211; Blocks<\/strong><\/h2>\n\n\n\n<p class=\"tw-highlight-padding\">Using curly brackets (<code><mark style=\"background-color:var(--base-3);color:#ff0000\" class=\"has-inline-color\">{}<\/mark><\/code>), multiple PHP statements can be performed simultaneously (under a single condition or loop) in PHP. <\/p>\n\n\n\n<p class=\"tw-highlight-padding\">This creates a block of concurrently performed statements.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>&lt;?php\n$x = 123;\nif ($x&lt;150){\n    echo (\"Variable x is \");\n    echo (\"lower than 150\");\n}\n?&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted tw-rounded\"><code>Variable x is lower than 150<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-contrast-3-color has-alpha-channel-opacity has-contrast-3-background-color has-background is-style-wide\"\/>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-related-articles\"><strong>Related Articles<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/itsourcecode.com\/php-tutorial\/php-ucwords-with-advanced-examples\/\">PHP Ucwords (With Advanced Examples)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/itsourcecode.com\/php-tutorial\/php-add-days-to-datetime-with-example\/\">PHP Add Days To Datetime With Example<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/itsourcecode.com\/php-tutorial\/php-trim-function-with-examples\/\">PHP Trim Function With Examples<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/itsourcecode.com\/php-tutorial\/types-of-operators-in-php-with-examples\/\">Types of Operators In PHP (With Examples)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/itsourcecode.com\/php-tutorial\/php-echo-array-with-example\/\">PHP Echo Array with Example<\/a><\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-summary\"><strong>Summary<\/strong><\/h2>\n\n\n\n<p>In summary, we&#8217;ve gone over the PHP Basic Syntax. We&#8217;ve explained each detail and shown you some examples for better understanding.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Lastly, if you want to learn more about the basic syntax of PHP, please leave a comment below. We\u2019ll be happy to hear it!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is basic PHP syntax? Basic PHP syntax is the set of rules that make up the structure of the PHP computer language. PHP, which stands for Hypertext Preprocessor, is &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"PHP Basic Syntax and Comments Overview (With Examples)\" class=\"read-more button\" href=\"https:\/\/itsourcecode.com\/php-tutorial\/php-basic-syntax-and-comments-overview-with-examples\/#more-77195\" aria-label=\"Read more about PHP Basic Syntax and Comments Overview (With Examples)\">Read more<\/a><\/p>\n","protected":false},"author":1373,"featured_media":77202,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61035],"tags":[95147,95145,95148,95149,95146],"class_list":["post-77195","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php-tutorial","tag-basic-syntax-of-php","tag-php-basic-syntax","tag-php-syntax-example","tag-php-syntax-with-example","tag-syntax-of-php","resize-featured-image"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.1 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>PHP Basic Syntax and Comments Overview (With Examples)<\/title>\n<meta name=\"description\" content=\"In this tutorial, we&#039;ll go over the basic syntax of PHP and Comments Overview, explaining it in great detail and showing you how it works.\u00a0\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/itsourcecode.com\/php-tutorial\/php-basic-syntax-and-comments-overview-with-examples\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PHP Basic Syntax and Comments Overview (With Examples)\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, we&#039;ll go over the basic syntax of PHP and Comments Overview, explaining it in great detail and showing you how it works.\u00a0\" \/>\n<meta property=\"og:url\" content=\"https:\/\/itsourcecode.com\/php-tutorial\/php-basic-syntax-and-comments-overview-with-examples\/\" \/>\n<meta property=\"og:site_name\" content=\"Itsourcecode.com\" \/>\n<meta property=\"article:author\" content=\"www.facebook.com\/unguardable7\" \/>\n<meta property=\"article:published_time\" content=\"2022-09-15T05:58:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-10-26T07:27:42+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/09\/PHP-Basic-Syntax.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1460\" \/>\n\t<meta property=\"og:image:height\" content=\"900\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Prince Ly Cesar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@http:\/\/www.twitter.com\/unguardable0729\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prince Ly Cesar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/php-tutorial\\\/php-basic-syntax-and-comments-overview-with-examples\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/php-tutorial\\\/php-basic-syntax-and-comments-overview-with-examples\\\/\"},\"author\":{\"name\":\"Prince Ly Cesar\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/#\\\/schema\\\/person\\\/8d6ff1c108160ddbd60ff17cbb9f626b\"},\"headline\":\"PHP Basic Syntax and Comments Overview (With Examples)\",\"datePublished\":\"2022-09-15T05:58:19+00:00\",\"dateModified\":\"2023-10-26T07:27:42+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/php-tutorial\\\/php-basic-syntax-and-comments-overview-with-examples\\\/\"},\"wordCount\":770,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/#\\\/schema\\\/person\\\/ad9e0497e03b85a9ca299d935298f5dc\"},\"image\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/php-tutorial\\\/php-basic-syntax-and-comments-overview-with-examples\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2022\\\/09\\\/PHP-Basic-Syntax.png\",\"keywords\":[\"basic syntax of php\",\"php basic syntax\",\"php syntax example\",\"php syntax with example\",\"syntax of php\"],\"articleSection\":[\"PHP Tutorial\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/itsourcecode.com\\\/php-tutorial\\\/php-basic-syntax-and-comments-overview-with-examples\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/php-tutorial\\\/php-basic-syntax-and-comments-overview-with-examples\\\/\",\"url\":\"https:\\\/\\\/itsourcecode.com\\\/php-tutorial\\\/php-basic-syntax-and-comments-overview-with-examples\\\/\",\"name\":\"PHP Basic Syntax and Comments Overview (With Examples)\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/php-tutorial\\\/php-basic-syntax-and-comments-overview-with-examples\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/php-tutorial\\\/php-basic-syntax-and-comments-overview-with-examples\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2022\\\/09\\\/PHP-Basic-Syntax.png\",\"datePublished\":\"2022-09-15T05:58:19+00:00\",\"dateModified\":\"2023-10-26T07:27:42+00:00\",\"description\":\"In this tutorial, we'll go over the basic syntax of PHP and Comments Overview, explaining it in great detail and showing you how it works.\u00a0\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/php-tutorial\\\/php-basic-syntax-and-comments-overview-with-examples\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/itsourcecode.com\\\/php-tutorial\\\/php-basic-syntax-and-comments-overview-with-examples\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/php-tutorial\\\/php-basic-syntax-and-comments-overview-with-examples\\\/#primaryimage\",\"url\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2022\\\/09\\\/PHP-Basic-Syntax.png\",\"contentUrl\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2022\\\/09\\\/PHP-Basic-Syntax.png\",\"width\":1460,\"height\":900,\"caption\":\"PHP Basic Syntax (Well Detailed Explanation & Examples)\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/php-tutorial\\\/php-basic-syntax-and-comments-overview-with-examples\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/itsourcecode.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PHP Basic Syntax and Comments Overview (With Examples)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/#website\",\"url\":\"https:\\\/\\\/itsourcecode.com\\\/\",\"name\":\"Itsourcecode.com\",\"description\":\"Partner In Your Coding Journey!\",\"publisher\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/#\\\/schema\\\/person\\\/ad9e0497e03b85a9ca299d935298f5dc\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/itsourcecode.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/#\\\/schema\\\/person\\\/ad9e0497e03b85a9ca299d935298f5dc\",\"name\":\"itsourcecode\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/IT-SOURCECODE_ICON-07.jpg\",\"url\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/IT-SOURCECODE_ICON-07.jpg\",\"contentUrl\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/IT-SOURCECODE_ICON-07.jpg\",\"width\":409,\"height\":409,\"caption\":\"itsourcecode\"},\"logo\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/IT-SOURCECODE_ICON-07.jpg\"},\"description\":\"Hello Itsourcecoders, welcome to itsourcecode.com. I'm Joken Villanueva, MIT a passionate Blogger, Programmer and a Hobbyist. I started Itsourcecode because I wanted to give back and Share all the learnings and knowledge I've learned in my career and I believe through this website I would be able to help and assist those newbie programmers in enhancing their skills from different programming languages. So let us all help each other by sharing our ideas!\",\"sameAs\":[\"https:\\\/\\\/itsourcecode.com\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/#\\\/schema\\\/person\\\/8d6ff1c108160ddbd60ff17cbb9f626b\",\"name\":\"Prince Ly Cesar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/litespeed\\\/avatar\\\/8fc9fa13530f18706fe0948f4673fae8.jpg?ver=1776478215\",\"url\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/litespeed\\\/avatar\\\/8fc9fa13530f18706fe0948f4673fae8.jpg?ver=1776478215\",\"contentUrl\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/litespeed\\\/avatar\\\/8fc9fa13530f18706fe0948f4673fae8.jpg?ver=1776478215\",\"caption\":\"Prince Ly Cesar\"},\"description\":\"Hi there! I'm Prince Ly Cesar a Student in Carlos Hilado Memorial State College - Binalbagan Campus and a Graphic Designer, Programmer &amp; Writer in IT SourceCode\",\"sameAs\":[\"https:\\\/\\\/activadorkeys.com\\\/\",\"www.facebook.com\\\/unguardable7\",\"http:\\\/\\\/www.instagram.com\\\/prnclycsr\\\/\",\"https:\\\/\\\/x.com\\\/http:\\\/\\\/www.twitter.com\\\/unguardable0729\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCF0BIqB5tpnCmwvYQCHucmw?view_as=subscriber\"],\"gender\":\"male\",\"knowsAbout\":[\"Graphic Designing\"],\"knowsLanguage\":[\"English\",\"Tagalog\"],\"jobTitle\":\"Graphic Designer\",\"worksFor\":\"IT SourceCode\",\"url\":\"https:\\\/\\\/itsourcecode.com\\\/author\\\/unguardable\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"PHP Basic Syntax and Comments Overview (With Examples)","description":"In this tutorial, we'll go over the basic syntax of PHP and Comments Overview, explaining it in great detail and showing you how it works.\u00a0","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:\/\/itsourcecode.com\/php-tutorial\/php-basic-syntax-and-comments-overview-with-examples\/","og_locale":"en_US","og_type":"article","og_title":"PHP Basic Syntax and Comments Overview (With Examples)","og_description":"In this tutorial, we'll go over the basic syntax of PHP and Comments Overview, explaining it in great detail and showing you how it works.\u00a0","og_url":"https:\/\/itsourcecode.com\/php-tutorial\/php-basic-syntax-and-comments-overview-with-examples\/","og_site_name":"Itsourcecode.com","article_author":"www.facebook.com\/unguardable7","article_published_time":"2022-09-15T05:58:19+00:00","article_modified_time":"2023-10-26T07:27:42+00:00","og_image":[{"width":1460,"height":900,"url":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/09\/PHP-Basic-Syntax.png","type":"image\/png"}],"author":"Prince Ly Cesar","twitter_card":"summary_large_image","twitter_creator":"@http:\/\/www.twitter.com\/unguardable0729","twitter_misc":{"Written by":"Prince Ly Cesar","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/itsourcecode.com\/php-tutorial\/php-basic-syntax-and-comments-overview-with-examples\/#article","isPartOf":{"@id":"https:\/\/itsourcecode.com\/php-tutorial\/php-basic-syntax-and-comments-overview-with-examples\/"},"author":{"name":"Prince Ly Cesar","@id":"https:\/\/itsourcecode.com\/#\/schema\/person\/8d6ff1c108160ddbd60ff17cbb9f626b"},"headline":"PHP Basic Syntax and Comments Overview (With Examples)","datePublished":"2022-09-15T05:58:19+00:00","dateModified":"2023-10-26T07:27:42+00:00","mainEntityOfPage":{"@id":"https:\/\/itsourcecode.com\/php-tutorial\/php-basic-syntax-and-comments-overview-with-examples\/"},"wordCount":770,"commentCount":1,"publisher":{"@id":"https:\/\/itsourcecode.com\/#\/schema\/person\/ad9e0497e03b85a9ca299d935298f5dc"},"image":{"@id":"https:\/\/itsourcecode.com\/php-tutorial\/php-basic-syntax-and-comments-overview-with-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/09\/PHP-Basic-Syntax.png","keywords":["basic syntax of php","php basic syntax","php syntax example","php syntax with example","syntax of php"],"articleSection":["PHP Tutorial"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/itsourcecode.com\/php-tutorial\/php-basic-syntax-and-comments-overview-with-examples\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/itsourcecode.com\/php-tutorial\/php-basic-syntax-and-comments-overview-with-examples\/","url":"https:\/\/itsourcecode.com\/php-tutorial\/php-basic-syntax-and-comments-overview-with-examples\/","name":"PHP Basic Syntax and Comments Overview (With Examples)","isPartOf":{"@id":"https:\/\/itsourcecode.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/itsourcecode.com\/php-tutorial\/php-basic-syntax-and-comments-overview-with-examples\/#primaryimage"},"image":{"@id":"https:\/\/itsourcecode.com\/php-tutorial\/php-basic-syntax-and-comments-overview-with-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/09\/PHP-Basic-Syntax.png","datePublished":"2022-09-15T05:58:19+00:00","dateModified":"2023-10-26T07:27:42+00:00","description":"In this tutorial, we'll go over the basic syntax of PHP and Comments Overview, explaining it in great detail and showing you how it works.\u00a0","breadcrumb":{"@id":"https:\/\/itsourcecode.com\/php-tutorial\/php-basic-syntax-and-comments-overview-with-examples\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/itsourcecode.com\/php-tutorial\/php-basic-syntax-and-comments-overview-with-examples\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/itsourcecode.com\/php-tutorial\/php-basic-syntax-and-comments-overview-with-examples\/#primaryimage","url":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/09\/PHP-Basic-Syntax.png","contentUrl":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/09\/PHP-Basic-Syntax.png","width":1460,"height":900,"caption":"PHP Basic Syntax (Well Detailed Explanation & Examples)"},{"@type":"BreadcrumbList","@id":"https:\/\/itsourcecode.com\/php-tutorial\/php-basic-syntax-and-comments-overview-with-examples\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/itsourcecode.com\/"},{"@type":"ListItem","position":2,"name":"PHP Basic Syntax and Comments Overview (With Examples)"}]},{"@type":"WebSite","@id":"https:\/\/itsourcecode.com\/#website","url":"https:\/\/itsourcecode.com\/","name":"Itsourcecode.com","description":"Partner In Your Coding Journey!","publisher":{"@id":"https:\/\/itsourcecode.com\/#\/schema\/person\/ad9e0497e03b85a9ca299d935298f5dc"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/itsourcecode.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/itsourcecode.com\/#\/schema\/person\/ad9e0497e03b85a9ca299d935298f5dc","name":"itsourcecode","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/01\/IT-SOURCECODE_ICON-07.jpg","url":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/01\/IT-SOURCECODE_ICON-07.jpg","contentUrl":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/01\/IT-SOURCECODE_ICON-07.jpg","width":409,"height":409,"caption":"itsourcecode"},"logo":{"@id":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/01\/IT-SOURCECODE_ICON-07.jpg"},"description":"Hello Itsourcecoders, welcome to itsourcecode.com. I'm Joken Villanueva, MIT a passionate Blogger, Programmer and a Hobbyist. I started Itsourcecode because I wanted to give back and Share all the learnings and knowledge I've learned in my career and I believe through this website I would be able to help and assist those newbie programmers in enhancing their skills from different programming languages. So let us all help each other by sharing our ideas!","sameAs":["https:\/\/itsourcecode.com\/"]},{"@type":"Person","@id":"https:\/\/itsourcecode.com\/#\/schema\/person\/8d6ff1c108160ddbd60ff17cbb9f626b","name":"Prince Ly Cesar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/itsourcecode.com\/wp-content\/litespeed\/avatar\/8fc9fa13530f18706fe0948f4673fae8.jpg?ver=1776478215","url":"https:\/\/itsourcecode.com\/wp-content\/litespeed\/avatar\/8fc9fa13530f18706fe0948f4673fae8.jpg?ver=1776478215","contentUrl":"https:\/\/itsourcecode.com\/wp-content\/litespeed\/avatar\/8fc9fa13530f18706fe0948f4673fae8.jpg?ver=1776478215","caption":"Prince Ly Cesar"},"description":"Hi there! I'm Prince Ly Cesar a Student in Carlos Hilado Memorial State College - Binalbagan Campus and a Graphic Designer, Programmer &amp; Writer in IT SourceCode","sameAs":["https:\/\/activadorkeys.com\/","www.facebook.com\/unguardable7","http:\/\/www.instagram.com\/prnclycsr\/","https:\/\/x.com\/http:\/\/www.twitter.com\/unguardable0729","https:\/\/www.youtube.com\/channel\/UCF0BIqB5tpnCmwvYQCHucmw?view_as=subscriber"],"gender":"male","knowsAbout":["Graphic Designing"],"knowsLanguage":["English","Tagalog"],"jobTitle":"Graphic Designer","worksFor":"IT SourceCode","url":"https:\/\/itsourcecode.com\/author\/unguardable\/"}]}},"_links":{"self":[{"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/posts\/77195","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/users\/1373"}],"replies":[{"embeddable":true,"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/comments?post=77195"}],"version-history":[{"count":12,"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/posts\/77195\/revisions"}],"predecessor-version":[{"id":119391,"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/posts\/77195\/revisions\/119391"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/media\/77202"}],"wp:attachment":[{"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/media?parent=77195"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/categories?post=77195"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/tags?post=77195"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}