{"id":317,"date":"2019-09-03T08:55:28","date_gmt":"2019-09-03T08:55:28","guid":{"rendered":"https:\/\/www.webhozz.com\/code\/?p=317"},"modified":"2019-09-03T08:55:30","modified_gmt":"2019-09-03T08:55:30","slug":"php-syntax","status":"publish","type":"post","link":"https:\/\/www.webhozz.com\/code\/php-syntax\/","title":{"rendered":"PHP : Syntax"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">PHP Syntax Standard<\/h2>\n\n\n\n<p>Script PHP dimulai dengan tag <strong><em>&lt;?php<\/em><\/strong> dan diakhiri\ndengan tag <strong><em>?&gt;<\/em><\/strong>.<\/p>\n\n\n\n<p>Pembatas PHP <strong><em>&lt;?php<\/em><\/strong> dan <strong><em>?><\/em><\/strong> Dalam contoh berikut hanya memberitahu PHP engine untuk memperlakukan blok kode terlampir sebagai kode PHP, daripada sekedar HTML sederhana.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&lt;?php\n\/\/ Some code to be executed\necho &quot;Hello, world!&quot;;\n?&gt;\n<\/pre><\/div>\n\n\n<p>Setiap pernyataan PHP diakhiri dengan tanda titik koma ( <strong><em>;<\/em><\/strong> ) &#8212;- ini memberitahu mesin PHP bahwa akhir dari pernyataan saat ini telah tercapai.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Embedding PHP ke dalam HTML<\/h5>\n\n\n\n<p>File PHP adalah file teks biasa dengan ekstensi <strong><em>.php<\/em><\/strong>. Di dalam file PHP kalian dapat menulis HTML seperti yang kalian lakukan di halaman HTML biasa serta menanamkan kode PHP untuk eksekusi server side.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&lt;!DOCTYPE html&gt;\n&lt;html lang=&quot;en&quot;&gt;\n&lt;head&gt;\n    &lt;meta charset=&quot;UTF-8&quot;&gt;\n    &lt;title&gt;A Simple PHP File&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n    &lt;h1&gt;&lt;?php echo &quot;Hello, world!&quot;; ?&gt;&lt;\/h1&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n<\/pre><\/div>\n\n\n<p>Contoh di atas menunjukkan bagaimana kalian dapat menanamkan\nkode PHP dalam HTML untuk membuat halaman web dinamis dengan baik. Jika kalian\nmelihat kode sumber dari halaman web yang dihasilkan di browser kalian,\nsatu-satunya perbedaan yang akan kalian lihat adalah kode PHP <strong><em>&lt;?php\necho &#8220;Hello, world!&#8221;; ?&gt;<\/em><\/strong> telah diganti dengan output <em>&#8220;Hello, world!&#8221;<\/em>.<\/p>\n\n\n\n<p>Apa yang terjadi di sini? ketika kalian menjalankan kode ini, PHP engine mengeluarkan instruksi di antara tag <strong><em>&lt;? php\u2026?><\/em><\/strong> dan membiarkan sisanya seperti apa adanya. Pada akhirnya server web mengirim hasil akhir kembali ke browser kalian yang sepenuhnya dalam HTML.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\"> PHP Comment <\/h5>\n\n\n\n<p>Sebuah komentar hanyalah teks sederhana yang diabaikan oleh PHP\nengine. Tujuan dari komentar adalah untuk membuat kode lebih mudah dibaca. Ini\ndapat membantu pengembang lain (atau bahkan kalian di masa depan ketika kalian\ningin mengedit kode sumber) untuk memahami apa yang kalian coba lakukan dengan\nPHP.<\/p>\n\n\n\n<p>PHP mendukung komentar <em>single-line<\/em> serta <em>multi-line<\/em>. Untuk menulis komentar single-line, mulailah baris dengan dua garis miring (\/\/) atau simbol hash (#). Sebagai contoh:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&lt;?php\n\/\/ This is a single line comment\n# This is also a single line comment\necho &quot;Hello, world!&quot;;\n?&gt;\n<\/pre><\/div>\n\n\n<p>Bagaimanapun untuk menulis komentar multi-line, mulailah komentar dengan garis miring (slash) diikuti oleh tanda bintang ( <strong><em>\/*<\/em><\/strong> ) dan akhiri komentar dengan tanda bintang diikuti tanda garis ( <strong><em>*\/<\/em><\/strong> ), seperti ini:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&lt;?php\n\/*\nThis is a multiple line comment block\nthat spans across more than\none line\n*\/\necho &quot;Hello, world!&quot;;\n?&gt;\n<\/pre><\/div>\n\n\n<h5 class=\"wp-block-heading\">Sensitivitas Huruf dalam PHP<\/h5>\n\n\n\n<p>Nama variabel di PHP peka huruf besar-kecil. Sebagai hasilnya, variabel <strong><em>$color<\/em><\/strong>, <strong><em>$Color<\/em><\/strong> dan <strong><em>$COLOR<\/em><\/strong> diperlakukan sebagai tiga variabel yang berbeda.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&lt;?php\n\/\/ Assign value to variable\n$color = &quot;blue&quot;;\n \n\/\/ Try to print variable value\necho &quot;The color of the sky is &quot; . $color . &quot;&lt;br&gt;&quot;;\necho &quot;The color of the sky is &quot; . $Color . &quot;&lt;br&gt;&quot;;\necho &quot;The color of the sky is &quot; . $COLOR . &quot;&lt;br&gt;&quot;;\n?&gt;\n<\/pre><\/div>\n\n\n<p>Jika kalian mencoba menjalankan kode contoh di atas, kode\nitu hanya akan menampilkan nilai variabel <strong><em>$color<\/em><\/strong> dan menghasilkan peringatan\n&#8220;<em>Undefined variable<\/em>&#8221; untuk\nvariabel <strong><em>$Color<\/em><\/strong> dan <strong><em>$COLOR<\/em><\/strong>.<\/p>\n\n\n\n<p>Namun kata kunci, fungsi, dan nama kelas tidak peka huruf besar-kecil. Akibatnya memanggil <strong><em>gettype()<\/em><\/strong> atau <strong><em>GETTYPE()<\/em><\/strong> menghasilkan hasil yang sama.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&lt;?php\n\/\/ Assign value to variable\n$color = &quot;blue&quot;;\n \n\/\/ Get the type of a variable\necho gettype($color) . &quot;&lt;br&gt;&quot;;\necho GETTYPE($color) . &quot;&lt;br&gt;&quot;;\n?&gt;\n<\/pre><\/div>\n\n\n<p>Jika kalian mencoba menjalankan kode contoh di atas, kedua\nfungsi <strong><em>gettype()<\/em><\/strong> dan <strong><em>GETTYPE()<\/em><\/strong> memberikan output yang\nsama, yaitu: <em>string<\/em>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP Syntax Standard Script PHP dimulai dengan tag &lt;?php dan diakhiri dengan tag ?&gt;. Pembatas PHP &lt;?php dan ?> Dalam contoh berikut hanya memberitahu PHP<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-317","post","type-post","status-publish","format-standard","hentry","category-php"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Belajar PHP : Syntax - WebHozz Code<\/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.webhozz.com\/code\/php-syntax\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Belajar PHP : Syntax - WebHozz Code\" \/>\n<meta property=\"og:description\" content=\"PHP Syntax Standard Script PHP dimulai dengan tag &lt;?php dan diakhiri dengan tag ?&gt;. Pembatas PHP &lt;?php dan ?&gt; Dalam contoh berikut hanya memberitahu PHP\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webhozz.com\/code\/php-syntax\/\" \/>\n<meta property=\"og:site_name\" content=\"WebHozz Code\" \/>\n<meta property=\"article:published_time\" content=\"2019-09-03T08:55:28+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-09-03T08:55:30+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\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.webhozz.com\\\/code\\\/php-syntax\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/php-syntax\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/#\\\/schema\\\/person\\\/3b2b79dc317236b0dde4b1fda37263e1\"},\"headline\":\"PHP : Syntax\",\"datePublished\":\"2019-09-03T08:55:28+00:00\",\"dateModified\":\"2019-09-03T08:55:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/php-syntax\\\/\"},\"wordCount\":377,\"articleSection\":[\"PHP\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/php-syntax\\\/\",\"url\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/php-syntax\\\/\",\"name\":\"Belajar PHP : Syntax - WebHozz Code\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/#website\"},\"datePublished\":\"2019-09-03T08:55:28+00:00\",\"dateModified\":\"2019-09-03T08:55:30+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/#\\\/schema\\\/person\\\/3b2b79dc317236b0dde4b1fda37263e1\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/php-syntax\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.webhozz.com\\\/code\\\/php-syntax\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/php-syntax\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PHP : Syntax\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/#website\",\"url\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/\",\"name\":\"WebHozz Code\",\"description\":\"Tutorial Web &amp; Pemrograman Indonesia\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/#\\\/schema\\\/person\\\/3b2b79dc317236b0dde4b1fda37263e1\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f222cb0ed38f2100d666bb262fd38d4f0d8e5673698208e40ff83118f10a4e8e?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f222cb0ed38f2100d666bb262fd38d4f0d8e5673698208e40ff83118f10a4e8e?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f222cb0ed38f2100d666bb262fd38d4f0d8e5673698208e40ff83118f10a4e8e?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"url\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/author\\\/dody\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Belajar PHP : Syntax - WebHozz Code","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.webhozz.com\/code\/php-syntax\/","og_locale":"en_US","og_type":"article","og_title":"Belajar PHP : Syntax - WebHozz Code","og_description":"PHP Syntax Standard Script PHP dimulai dengan tag &lt;?php dan diakhiri dengan tag ?&gt;. Pembatas PHP &lt;?php dan ?> Dalam contoh berikut hanya memberitahu PHP","og_url":"https:\/\/www.webhozz.com\/code\/php-syntax\/","og_site_name":"WebHozz Code","article_published_time":"2019-09-03T08:55:28+00:00","article_modified_time":"2019-09-03T08:55:30+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webhozz.com\/code\/php-syntax\/#article","isPartOf":{"@id":"https:\/\/www.webhozz.com\/code\/php-syntax\/"},"author":{"name":"admin","@id":"https:\/\/www.webhozz.com\/code\/#\/schema\/person\/3b2b79dc317236b0dde4b1fda37263e1"},"headline":"PHP : Syntax","datePublished":"2019-09-03T08:55:28+00:00","dateModified":"2019-09-03T08:55:30+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webhozz.com\/code\/php-syntax\/"},"wordCount":377,"articleSection":["PHP"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.webhozz.com\/code\/php-syntax\/","url":"https:\/\/www.webhozz.com\/code\/php-syntax\/","name":"Belajar PHP : Syntax - WebHozz Code","isPartOf":{"@id":"https:\/\/www.webhozz.com\/code\/#website"},"datePublished":"2019-09-03T08:55:28+00:00","dateModified":"2019-09-03T08:55:30+00:00","author":{"@id":"https:\/\/www.webhozz.com\/code\/#\/schema\/person\/3b2b79dc317236b0dde4b1fda37263e1"},"breadcrumb":{"@id":"https:\/\/www.webhozz.com\/code\/php-syntax\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webhozz.com\/code\/php-syntax\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.webhozz.com\/code\/php-syntax\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webhozz.com\/code\/"},{"@type":"ListItem","position":2,"name":"PHP : Syntax"}]},{"@type":"WebSite","@id":"https:\/\/www.webhozz.com\/code\/#website","url":"https:\/\/www.webhozz.com\/code\/","name":"WebHozz Code","description":"Tutorial Web &amp; Pemrograman Indonesia","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webhozz.com\/code\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.webhozz.com\/code\/#\/schema\/person\/3b2b79dc317236b0dde4b1fda37263e1","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/f222cb0ed38f2100d666bb262fd38d4f0d8e5673698208e40ff83118f10a4e8e?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/f222cb0ed38f2100d666bb262fd38d4f0d8e5673698208e40ff83118f10a4e8e?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f222cb0ed38f2100d666bb262fd38d4f0d8e5673698208e40ff83118f10a4e8e?s=96&d=mm&r=g","caption":"admin"},"url":"https:\/\/www.webhozz.com\/code\/author\/dody\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webhozz.com\/code\/wp-json\/wp\/v2\/posts\/317","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webhozz.com\/code\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webhozz.com\/code\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webhozz.com\/code\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webhozz.com\/code\/wp-json\/wp\/v2\/comments?post=317"}],"version-history":[{"count":1,"href":"https:\/\/www.webhozz.com\/code\/wp-json\/wp\/v2\/posts\/317\/revisions"}],"predecessor-version":[{"id":318,"href":"https:\/\/www.webhozz.com\/code\/wp-json\/wp\/v2\/posts\/317\/revisions\/318"}],"wp:attachment":[{"href":"https:\/\/www.webhozz.com\/code\/wp-json\/wp\/v2\/media?parent=317"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webhozz.com\/code\/wp-json\/wp\/v2\/categories?post=317"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webhozz.com\/code\/wp-json\/wp\/v2\/tags?post=317"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}