{"id":794,"date":"2017-11-15T14:31:10","date_gmt":"2017-11-15T07:31:10","guid":{"rendered":"http:\/\/www.yellowweb.id\/blog\/?p=794"},"modified":"2017-11-15T14:31:10","modified_gmt":"2017-11-15T07:31:10","slug":"php-function","status":"publish","type":"post","link":"https:\/\/www.yellowweb.id\/blog\/php-function\/","title":{"rendered":"PHP Function"},"content":{"rendered":"<p>Mungkin teman-teman mengalami kendala disaat membuat sebuah kode pemrograman yang cukup besar, hal ini ditemui disaat teman-teman mengalami kesalahan dalam penulisan sebuah program, karena penulisan kode sudah begitu banyak maka akan menghabisakan waktu juga untuk melacak kesalahan dari baris ke baris.<br \/>\n<!--more--><\/p>\n<p>Kita dapat menggunakan function PHP, ya kita dapat dengan mudah, misalnya perintah untuk menghapus, login atau upload. Disini dibuatkan function hapus atau upload, dimana kita tinggal memanggil nama function tersebut. Sederhananya kita lihat contoh berikut ini:<\/p>\n<pre class=\"lang:php decode:true \">&lt;?php\r\n\tfunction penjumlahan($nilai1, $nilai2){\r\n\t\t\/\/ kode program\r\n\t\t$x = $nilai1;\r\n\t\t$y = $nilai2;\r\n\r\n\t\t$hasil = $x+$y;\r\n\r\n\t\treturn $hasil; \r\n\t}\r\n\r\n\t\/\/ panggil nama fungsi\r\n\t$hasil = penjumlahan(3,5);\r\n\techo \"Penjumlahan 3 + 5 hasilnya $hasil\";\r\n\techo \"&lt;br&gt;\";\r\n\r\n\t\/\/ dengan cara yang berbeda\r\n\techo \"Hasil penjumlahan 4 + 2 adalah \".penjumlahan(4, 2);\r\n?&gt;<\/pre>\n<p>Dari skrip diatas ada beberapa hal yang perlu kita perhatikan, diantaranya<br \/>\n1. Disana tertulis bahwa kita membuat <span style=\"color: #0000ff;\">function dengan nama penjumlahan<\/span><br \/>\n2. Kita menjumpai dua argumen yang memiliki <span style=\"color: #0000ff;\">parameter $nilai1<\/span> dan $nilai2<br \/>\n3. <span style=\"color: #0000ff;\">$hasil<\/span> yang menampung <span style=\"color: #0000ff;\">$x<\/span> dan<span style=\"color: #0000ff;\"> $y<\/span> dengan menambahkan<span style=\"color: #0000ff;\"> operator aritmatik penjumlahan<\/span><br \/>\n4. <span style=\"color: #0000ff;\">Return<\/span> disini memberikan perintah bahwa kode program telah selesai, dan akan dikembalikan ke function (penjumlahan) <span style=\"color: #0000ff;\">untuk di cetak nantinya.<\/span><\/p>\n<p>Function diatas kita mencoba mencetak dengan dua cara ya teman-teman.<br \/>\nSemoga artikel yang singkat ini bisa memberikan sedikit gambaran atau tambahan wawasan bagi teman-teman yang baru mencoba mempelajari PHP.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mungkin teman-teman mengalami kendala disaat membuat sebuah kode pemrograman yang cukup besar, hal ini ditemui disaat teman-teman mengalami kesalahan dalam penulisan sebuah program, karena penulisan kode sudah begitu banyak maka akan menghabisakan waktu juga untuk melacak kesalahan dari baris ke baris.<\/p>\n","protected":false},"author":1,"featured_media":797,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[110],"tags":[379,380,88,381],"class_list":["post-794","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-functions","tag-operator","tag-php","tag-tipe"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PHP Function - YELLOWWEB.ID<\/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.yellowweb.id\/blog\/php-function\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PHP Function - YELLOWWEB.ID\" \/>\n<meta property=\"og:description\" content=\"Mungkin teman-teman mengalami kendala disaat membuat sebuah kode pemrograman yang cukup besar, hal ini ditemui disaat teman-teman mengalami kesalahan dalam penulisan sebuah program, karena penulisan kode sudah begitu banyak maka akan menghabisakan waktu juga untuk melacak kesalahan dari baris ke baris.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.yellowweb.id\/blog\/php-function\/\" \/>\n<meta property=\"og:site_name\" content=\"YELLOWWEB.ID\" \/>\n<meta property=\"article:published_time\" content=\"2017-11-15T07:31:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/i0.wp.com\/www.yellowweb.id\/blog\/wp-content\/uploads\/2017\/11\/php-functioons.jpg?fit=600%2C290&ssl=1\" \/>\n\t<meta property=\"og:image:width\" content=\"600\" \/>\n\t<meta property=\"og:image:height\" content=\"290\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"yellowweb\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"yellowweb\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/php-function\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/php-function\\\/\"},\"author\":{\"name\":\"yellowweb\",\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/#\\\/schema\\\/person\\\/75188044e080844724e381ab6a5b9829\"},\"headline\":\"PHP Function\",\"datePublished\":\"2017-11-15T07:31:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/php-function\\\/\"},\"wordCount\":168,\"image\":{\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/php-function\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/11\\\/php-functioons.jpg\",\"keywords\":[\"functions\",\"operator\",\"php\",\"tipe\"],\"articleSection\":[\"PHP\"],\"inLanguage\":\"en-GB\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/php-function\\\/\",\"url\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/php-function\\\/\",\"name\":\"PHP Function - YELLOWWEB.ID\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/php-function\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/php-function\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/11\\\/php-functioons.jpg\",\"datePublished\":\"2017-11-15T07:31:10+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/#\\\/schema\\\/person\\\/75188044e080844724e381ab6a5b9829\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/php-function\\\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/php-function\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/php-function\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/11\\\/php-functioons.jpg\",\"contentUrl\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/11\\\/php-functioons.jpg\",\"width\":600,\"height\":290,\"caption\":\"php-functioons\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/php-function\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PHP Function\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/\",\"name\":\"YELLOWWEB.ID\",\"description\":\"Kursus Web Design | Kursus Web Programming | Mobile Web Apps | Digital Marketing\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/#\\\/schema\\\/person\\\/75188044e080844724e381ab6a5b9829\",\"name\":\"yellowweb\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5afd1bfac26e9377e8f5e36afb624cf3690dd31cb07c3961dfbc736b9ff1912f?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5afd1bfac26e9377e8f5e36afb624cf3690dd31cb07c3961dfbc736b9ff1912f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5afd1bfac26e9377e8f5e36afb624cf3690dd31cb07c3961dfbc736b9ff1912f?s=96&d=mm&r=g\",\"caption\":\"yellowweb\"},\"sameAs\":[\"https:\\\/\\\/www.yellowweb.id\"],\"url\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/author\\\/yellowweb\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PHP Function - YELLOWWEB.ID","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.yellowweb.id\/blog\/php-function\/","og_locale":"en_GB","og_type":"article","og_title":"PHP Function - YELLOWWEB.ID","og_description":"Mungkin teman-teman mengalami kendala disaat membuat sebuah kode pemrograman yang cukup besar, hal ini ditemui disaat teman-teman mengalami kesalahan dalam penulisan sebuah program, karena penulisan kode sudah begitu banyak maka akan menghabisakan waktu juga untuk melacak kesalahan dari baris ke baris.","og_url":"https:\/\/www.yellowweb.id\/blog\/php-function\/","og_site_name":"YELLOWWEB.ID","article_published_time":"2017-11-15T07:31:10+00:00","og_image":[{"width":600,"height":290,"url":"https:\/\/i0.wp.com\/www.yellowweb.id\/blog\/wp-content\/uploads\/2017\/11\/php-functioons.jpg?fit=600%2C290&ssl=1","type":"image\/jpeg"}],"author":"yellowweb","twitter_card":"summary_large_image","twitter_misc":{"Written by":"yellowweb","Estimated reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.yellowweb.id\/blog\/php-function\/#article","isPartOf":{"@id":"https:\/\/www.yellowweb.id\/blog\/php-function\/"},"author":{"name":"yellowweb","@id":"https:\/\/www.yellowweb.id\/blog\/#\/schema\/person\/75188044e080844724e381ab6a5b9829"},"headline":"PHP Function","datePublished":"2017-11-15T07:31:10+00:00","mainEntityOfPage":{"@id":"https:\/\/www.yellowweb.id\/blog\/php-function\/"},"wordCount":168,"image":{"@id":"https:\/\/www.yellowweb.id\/blog\/php-function\/#primaryimage"},"thumbnailUrl":"https:\/\/www.yellowweb.id\/blog\/wp-content\/uploads\/2017\/11\/php-functioons.jpg","keywords":["functions","operator","php","tipe"],"articleSection":["PHP"],"inLanguage":"en-GB"},{"@type":"WebPage","@id":"https:\/\/www.yellowweb.id\/blog\/php-function\/","url":"https:\/\/www.yellowweb.id\/blog\/php-function\/","name":"PHP Function - YELLOWWEB.ID","isPartOf":{"@id":"https:\/\/www.yellowweb.id\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.yellowweb.id\/blog\/php-function\/#primaryimage"},"image":{"@id":"https:\/\/www.yellowweb.id\/blog\/php-function\/#primaryimage"},"thumbnailUrl":"https:\/\/www.yellowweb.id\/blog\/wp-content\/uploads\/2017\/11\/php-functioons.jpg","datePublished":"2017-11-15T07:31:10+00:00","author":{"@id":"https:\/\/www.yellowweb.id\/blog\/#\/schema\/person\/75188044e080844724e381ab6a5b9829"},"breadcrumb":{"@id":"https:\/\/www.yellowweb.id\/blog\/php-function\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.yellowweb.id\/blog\/php-function\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.yellowweb.id\/blog\/php-function\/#primaryimage","url":"https:\/\/www.yellowweb.id\/blog\/wp-content\/uploads\/2017\/11\/php-functioons.jpg","contentUrl":"https:\/\/www.yellowweb.id\/blog\/wp-content\/uploads\/2017\/11\/php-functioons.jpg","width":600,"height":290,"caption":"php-functioons"},{"@type":"BreadcrumbList","@id":"https:\/\/www.yellowweb.id\/blog\/php-function\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.yellowweb.id\/blog\/"},{"@type":"ListItem","position":2,"name":"PHP Function"}]},{"@type":"WebSite","@id":"https:\/\/www.yellowweb.id\/blog\/#website","url":"https:\/\/www.yellowweb.id\/blog\/","name":"YELLOWWEB.ID","description":"Kursus Web Design | Kursus Web Programming | Mobile Web Apps | Digital Marketing","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.yellowweb.id\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Person","@id":"https:\/\/www.yellowweb.id\/blog\/#\/schema\/person\/75188044e080844724e381ab6a5b9829","name":"yellowweb","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/secure.gravatar.com\/avatar\/5afd1bfac26e9377e8f5e36afb624cf3690dd31cb07c3961dfbc736b9ff1912f?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/5afd1bfac26e9377e8f5e36afb624cf3690dd31cb07c3961dfbc736b9ff1912f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5afd1bfac26e9377e8f5e36afb624cf3690dd31cb07c3961dfbc736b9ff1912f?s=96&d=mm&r=g","caption":"yellowweb"},"sameAs":["https:\/\/www.yellowweb.id"],"url":"https:\/\/www.yellowweb.id\/blog\/author\/yellowweb\/"}]}},"_links":{"self":[{"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/posts\/794","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/comments?post=794"}],"version-history":[{"count":2,"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/posts\/794\/revisions"}],"predecessor-version":[{"id":796,"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/posts\/794\/revisions\/796"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/media\/797"}],"wp:attachment":[{"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/media?parent=794"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/categories?post=794"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/tags?post=794"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}