{"id":1661,"date":"2009-08-11T16:29:58","date_gmt":"2009-08-11T14:29:58","guid":{"rendered":"http:\/\/localhost\/helpcentre\/?p=1661"},"modified":"2022-11-10T12:19:43","modified_gmt":"2022-11-10T10:19:43","slug":"how-does-arithmetic-operators-work-in-php","status":"publish","type":"post","link":"https:\/\/xneelo.co.za\/help-centre\/website\/how-does-arithmetic-operators-work-in-php\/","title":{"rendered":"How does \u2018Arithmetic Operators\u2019 work in PHP?"},"content":{"rendered":"<p><b>Arithmetic Operators<\/b> in PHP are virtually identical to those in Perl, as illustrated by the example code below:<\/p>\n<div class=\"codeblock\"><code><code><span style=\"color: #000000;\"><br \/>\n<span style=\"color: #ff8000;\">\/\/ Addition<br \/>\n<\/span><span style=\"color: #0000bb;\">$ADD <\/span><span style=\"color: #007700;\">= <\/span><span style=\"color: #0000bb;\">$VAR <\/span><span style=\"color: #007700;\">+ <\/span><span style=\"color: #0000bb;\">3<\/span><span style=\"color: #007700;\">;<\/span><\/span><\/code><\/code><code><code><span style=\"color: #000000;\"><span style=\"color: #ff8000;\">\/\/ Subtraction<br \/>\n<\/span><span style=\"color: #0000bb;\">$SUB <\/span><span style=\"color: #007700;\">= <\/span><span style=\"color: #0000bb;\">18 <\/span><span style=\"color: #007700;\">- <\/span><span style=\"color: #0000bb;\">6<\/span><span style=\"color: #007700;\">;<\/span><\/span><\/code><\/code><\/p>\n<p><code><code><span style=\"color: #000000;\"><span style=\"color: #ff8000;\">\/\/ Multiplication<br \/>\n<\/span><span style=\"color: #0000bb;\">$MULT <\/span><span style=\"color: #007700;\">= <\/span><span style=\"color: #0000bb;\">$VAR1 <\/span><span style=\"color: #007700;\">* <\/span><span style=\"color: #0000bb;\">$VAR2<\/span><span style=\"color: #007700;\">;<\/span><\/span><\/code><\/code><\/p>\n<p><code><code><span style=\"color: #000000;\"><span style=\"color: #ff8000;\">\/\/ Division<br \/>\n<\/span><span style=\"color: #0000bb;\">$DIV <\/span><span style=\"color: #007700;\">= <\/span><span style=\"color: #0000bb;\">15 <\/span><span style=\"color: #007700;\">\/ <\/span><span style=\"color: #0000bb;\">$VAR<\/span><span style=\"color: #007700;\">;<\/span><\/span><\/code><\/code><\/p>\n<p><code><span style=\"color: #000000;\"><span style=\"color: #ff8000;\">\/\/ Modulus (Division to get remainder)<br \/>\n<\/span><span style=\"color: #0000bb;\">$MOD <\/span><span style=\"color: #007700;\">= <\/span><span style=\"color: #0000bb;\">$VAR <\/span><span style=\"color: #007700;\">% <\/span><span style=\"color: #0000bb;\">2<\/span><span style=\"color: #007700;\">;<br \/>\n<\/span><span style=\"color: #0000bb;\">?&gt; <\/span><br \/>\n<\/span><br \/>\n<\/code><\/p>\n<\/div>\n","protected":false,"plain":"<b>Arithmetic Operators<\/b> in PHP are virtually identical to those in Perl, as illustrated by the example code below:\r\n<div class=\"codeblock\"><code><code><span >\r\n<span >\/\/ Addition\r\n<\/span><span >$ADD <\/span><span >= <\/span><span >$VAR <\/span><span >+ <\/span><span >3<\/span><span >;<\/span><\/span><\/code><\/code><code><code><span ><span >\/\/ Subtraction\r\n<\/span><span >$SUB <\/span><span >= <\/span><span >18 <\/span><span >- <\/span><span >6<\/span><span >;<\/span><\/span><\/code><\/code>\r\n\r\n<code><code><span ><span >\/\/ Multiplication\r\n<\/span><span >$MULT <\/span><span >= <\/span><span >$VAR1 <\/span><span >* <\/span><span >$VAR2<\/span><span >;<\/span><\/span><\/code><\/code>\r\n\r\n<code><code><span ><span >\/\/ Division\r\n<\/span><span >$DIV <\/span><span >= <\/span><span >15 <\/span><span >\/ <\/span><span >$VAR<\/span><span >;<\/span><\/span><\/code><\/code>\r\n\r\n<code><span ><span >\/\/ Modulus (Division to get remainder)\r\n<\/span><span >$MOD <\/span><span >= <\/span><span >$VAR <\/span><span >% <\/span><span >2<\/span><span >;\r\n<\/span><span >?&gt; <\/span>\r\n<\/span>\r\n<\/code>\r\n\r\n<\/div>"},"excerpt":{"rendered":"<p>Arithmetic Operators in PHP are virtually identical to those in Perl. We illustrate this similarity with an example in this article. <\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"lsx_disable_title":"0","_relevanssi_hide_post":"","_relevanssi_hide_content":"","_relevanssi_pin_for_all":"","_relevanssi_pin_keywords":"","_relevanssi_unpin_keywords":"","_relevanssi_related_keywords":"","_relevanssi_related_include_ids":"","_relevanssi_related_exclude_ids":"","_relevanssi_related_no_append":"","_relevanssi_related_not_related":"","_relevanssi_related_posts":"","_relevanssi_noindex_reason":"","footnotes":""},"categories":[179,166],"tags":[17168,17165],"topics":[],"class_list":["post-1661","post","type-post","status-publish","format-standard","hentry","category-php","category-website","tag-php","tag-arithmetic-operators"],"acf":[],"additional_meta":{"category_title":[{"term_id":179,"name":"PHP","slug":"php","term_group":0,"term_taxonomy_id":179,"taxonomy":"category","description":"Allowing you to create dynamic content that interacts with databases","parent":168,"count":20,"filter":"raw","term_order":"97","cat_ID":179,"category_count":20,"category_description":"Allowing you to create dynamic content that interacts with databases","cat_name":"PHP","category_nicename":"php","category_parent":168},{"term_id":166,"name":"Website","slug":"website","term_group":0,"term_taxonomy_id":166,"taxonomy":"category","description":"About your Website(s)","parent":0,"count":169,"filter":"raw","term_order":"120","cat_ID":166,"category_count":169,"category_description":"About your Website(s)","cat_name":"Website","category_nicename":"website","category_parent":0}],"tag_title":[{"term_id":17168,"name":"php","slug":"php","term_group":0,"term_taxonomy_id":17168,"taxonomy":"post_tag","description":"","parent":0,"count":16,"filter":"raw","term_order":"2400"},{"term_id":17165,"name":"Arithmetic Operators","slug":"arithmetic-operators","term_group":0,"term_taxonomy_id":17165,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw","term_order":"2402"}]},"featured_image_src":null,"author_info":{"display_name":"marketing","author_link":"https:\/\/xneelo.co.za\/help-centre\/author\/marketing\/","author_avatar":"https:\/\/secure.gravatar.com\/avatar\/a6ea315e112423b2b955cb020fbce2b0835956c6ad85ff0f13f1db298977eaaa?s=96&d=mm&r=g"},"_links":{"self":[{"href":"https:\/\/xneelo.co.za\/help-centre\/wp-json\/wp\/v2\/posts\/1661","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xneelo.co.za\/help-centre\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xneelo.co.za\/help-centre\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xneelo.co.za\/help-centre\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/xneelo.co.za\/help-centre\/wp-json\/wp\/v2\/comments?post=1661"}],"version-history":[{"count":0,"href":"https:\/\/xneelo.co.za\/help-centre\/wp-json\/wp\/v2\/posts\/1661\/revisions"}],"wp:attachment":[{"href":"https:\/\/xneelo.co.za\/help-centre\/wp-json\/wp\/v2\/media?parent=1661"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xneelo.co.za\/help-centre\/wp-json\/wp\/v2\/categories?post=1661"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xneelo.co.za\/help-centre\/wp-json\/wp\/v2\/tags?post=1661"},{"taxonomy":"topics","embeddable":true,"href":"https:\/\/xneelo.co.za\/help-centre\/wp-json\/wp\/v2\/topics?post=1661"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}