{"id":10570,"date":"2020-02-17T08:09:07","date_gmt":"2020-02-17T08:09:07","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=10570"},"modified":"2021-11-12T10:35:44","modified_gmt":"2021-11-12T10:35:44","slug":"what-are-comments-constant-variable-string-interpolation-arithmetic-and-assignment-operators-in-php","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/what-are-comments-constant-variable-string-interpolation-arithmetic-and-assignment-operators-in-php\/","title":{"rendered":"What are Comments, Constant Variable, String Interpolation, Arithmetic and Assignment Operators in PHP?"},"content":{"rendered":"\n<h1 class=\"has-text-align-center wp-block-heading\"><em>Comments in PHP<\/em><\/h1>\n\n\n\n<p><em>Comments are those human-readable texts that we should add to make our code more understandable for other programmes. It is ignored by PHP and doesn&#8217;t affect your code.<\/em><\/p>\n\n\n\n<p><em><strong>Comment are of Two types.<\/strong><\/em><br> i. One or Single-line Comment.<br> ii. Multi-line Comment.<\/p>\n\n\n\n<p><strong><em>i. One or Single-line Comment:- <\/em><\/strong>Single line Comment is used to comment one line at a time or used in one line.<\/p>\n\n\n\n<p> <em>There are two types of Single line Comment:-<\/em><\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Starts with \/\/ <br> <strong>Ex-<\/strong> \/\/this is home section.<\/li><li>Starts with #  <br> <strong>Ex-<\/strong> # this is footer section.<\/li><\/ol>\n\n\n\n<p><strong><em>ii. Multi-line Comment:-<\/em><\/strong> It is used to comment more than one line at a time or used in more than one line. It starts with \/* and ends with *<em>\/. <\/em><\/p>\n\n\n\n<p><strong>Ex &#8211;<\/strong>   \/* this is <br>         a multi-line<br>         Comment*\/<\/p>\n\n\n\n<h1 class=\"has-text-align-center wp-block-heading\"><em>String Interpolation<\/em><\/h1>\n\n\n\n<p>String Interpolation is a feature or a quick shortcut which allows popping the value of a variable into a double-quoted string.<\/p>\n\n\n\n<p><strong>Ex &#8211;<\/strong> <em>{Without String Interpolation}<\/em><\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/SushantSinghRajput03\/e5ab6fbb42cc2d5d3fa8d9a4e25410b6.js\"><\/script>\n\n\n\n<p>        <em>{With String Interpolation}<\/em><\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/SushantSinghRajput03\/20760875347c993d5cb91fcdd550e85c.js\"><\/script>\n\n\n\n<h1 class=\"has-text-align-center wp-block-heading\"><em>Constant Variable<\/em><\/h1>\n\n\n\n<p><em>It is a type of variable which can&#8217;t be modified. To create a constant variable define() function is used.<\/em><\/p>\n\n\n\n<p> <strong><em>Syntax :-<\/em><\/strong> <em>define(&#8220;constant_variable&#8221;,value,case-insensitive);<\/em><\/p>\n\n\n\n<p><strong><em>Ex &#8211; <\/em><\/strong><em>define(&#8220;pi&#8221;,3.1415,True);<\/em>  {<strong><em>Note:-<\/em><\/strong> If case-insensitive is not assigned then, its by default <em>FALSE<\/em>}<\/p>\n\n\n\n<p><strong><em>Rules of Constant Varible :-<\/em><\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>No need to start the constant varible with the $ sign.<\/li><li>Name only starts with a letter and an underscore(_).<\/li><li>Variable name can&#8217;t start with a number.<\/li><li>Constants are automatically global and can be used in the entire script.<\/li><\/ol>\n\n\n\n<h1 class=\"has-text-align-center wp-block-heading\"><em>Arithmetic\/Math Operators<\/em><\/h1>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"657\" height=\"254\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/Arithmetic-Operators.png\" alt=\"\" class=\"wp-image-10592\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/Arithmetic-Operators.png 657w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/Arithmetic-Operators-300x116.png 300w\" sizes=\"auto, (max-width: 657px) 100vw, 657px\" \/><\/figure>\n\n\n\n<h1 class=\"has-text-align-center wp-block-heading\"><em>Sample Program<\/em><\/h1>\n\n\n\n<script src=\"https:\/\/gist.github.com\/SushantSinghRajput03\/f394aa27e9500b2ee72b81e617206a1f.js\"><\/script>\n\n\n\n<h1 class=\"has-text-align-center wp-block-heading\"><em>Output<\/em> <\/h1>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"386\" height=\"152\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/Arithmetic-Operators-Example.png\" alt=\"\" class=\"wp-image-10599\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/Arithmetic-Operators-Example.png 386w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/Arithmetic-Operators-Example-300x118.png 300w\" sizes=\"auto, (max-width: 386px) 100vw, 386px\" \/><\/figure><\/div>\n\n\n\n<h1 class=\"has-text-align-center wp-block-heading\"><em>Maths Functions<\/em><\/h1>\n\n\n\n<p>There are predefined mathematical Functions available in PHP to do the mathematics calculations.  <strong><em>See the below list:-<\/em><\/strong> <\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/SushantSinghRajput03\/18aee1303027b5bfe41f1de32c80aa23.js\"><\/script>\n\n\n\n<h1 class=\"has-text-align-center wp-block-heading\"><em>Assignment Operators<\/em><\/h1>\n\n\n\n<p>This operator is used to assign value to the variables. <strong>For Ex &#8211;<\/strong>    <\/p>\n\n\n\n<p><em>$price=39.12<\/em> , <em>$ram=$shyam=10<\/em> , $name=sushant<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"501\" height=\"201\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/Untitled-Diagram.png\" alt=\"\" class=\"wp-image-10609\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/Untitled-Diagram.png 501w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/Untitled-Diagram-300x120.png 300w\" sizes=\"auto, (max-width: 501px) 100vw, 501px\" \/><\/figure><\/div>\n\n\n\n<p>In the above example, Assignment operator (<strong><em>=<\/em><\/strong>) is used to assign the value (<strong><em>36.58<\/em><\/strong>) to the variable (<strong><em>$price<\/em><\/strong>).<\/p>\n\n\n\n<h3 class=\"has-text-align-center wp-block-heading\">Combined Assignment Operator <\/h3>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"588\" height=\"178\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/Combined-Assignment-Operators.png\" alt=\"\" class=\"wp-image-10617\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/Combined-Assignment-Operators.png 588w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/Combined-Assignment-Operators-300x91.png 300w\" sizes=\"auto, (max-width: 588px) 100vw, 588px\" \/><\/figure><\/div>\n\n\n\n<h1 class=\"has-text-align-center wp-block-heading\">Sample Program<\/h1>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/Combined-Assignment-Operator-program.png\" alt=\"\" class=\"wp-image-10686\" width=\"176\" height=\"114\"\/><\/figure><\/div>\n\n\n\n<h3 class=\"has-text-align-center wp-block-heading\">Output<\/h3>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"363\" height=\"93\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/Combined-Assignment-Operator-Output.png\" alt=\"\" class=\"wp-image-10687\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/Combined-Assignment-Operator-Output.png 363w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/Combined-Assignment-Operator-Output-300x77.png 300w\" sizes=\"auto, (max-width: 363px) 100vw, 363px\" \/><\/figure><\/div>\n\n\n\n<p>To know more about Assignment Operator Click here &#8211; <a rel=\"noopener noreferrer\" target=\"_blank\" href=\"https:\/\/www.youtube.com\/watch?v=cP5NRORfIw4&amp;list=PLbGui_ZYuhigFdLdbSI2EM2MrJB7I0j-B&amp;index=27\">Assignment Operators<\/a><\/p>\n\n\n\n<p> Click Here For Next Part \u2013\u00a0  <a href=\"https:\/\/www.devopsschool.com\/blog\/what-are-if-nested-if-if-else-and-nested-if-else-statement-in-php\/\">What are If, Nested if, if else and, Nested if else Statement in PHP?<\/a> <\/p>\n\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_70024\"><figure class=\"wp-block-embed wp-block-embed-youtube is-type-video is-provider-youtube epyt-figure\"><div class=\"wp-block-embed__wrapper\"><iframe loading=\"lazy\"  id=\"_ytid_84641\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_70024\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><\/div><\/figure><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Comments in PHP Comments are those human-readable texts that we should add to make our code more understandable for other programmes. It is ignored by PHP and doesn&#8217;t affect your code. Comment are of Two types. i. One or Single-line Comment. ii. Multi-line Comment. i. One or Single-line Comment:- Single line Comment is used to&#8230;<\/p>\n","protected":false},"author":19,"featured_media":10841,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[5150],"tags":[5921,5918,5920,177,5858,5867,5919,5859],"class_list":["post-10570","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-arithmetic-operators","tag-comments-in-php","tag-constant-variable","tag-php","tag-php-tutorial","tag-php-tutorial-2020","tag-string-interpolation","tag-tutorial-for-beginners"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/10570","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=10570"}],"version-history":[{"count":68,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/10570\/revisions"}],"predecessor-version":[{"id":24944,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/10570\/revisions\/24944"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/10841"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=10570"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=10570"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=10570"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}