Belajar PHP: Perbedaan Fungsi echo(), print(), dan printf() pada PHP

PHP memiliki beberapa fungsi untuk mencetak teks ke layar:

fungsi echo();
fungsi print();
fungsi printf().

Fungsi-fungsi ini akan sering kita gunakan dalam pemrograman PHP.

Lalu, apa saja sih perbedaan dari tiga fungsi ini?

Mari kita bahas…
Fungsi echo()

Fungi echo() adalah fungsi untuk menampilkan teks ke layar. Fungsi ini dapat digunakan dengan tanda kurung maupun tanpa tanda kurung.

echo "<h2>Belajar PHP itu mudah!</h2>";
echo("Hello world!<br>");
echo "Aku sedang belajar PHP!<br>";
echo "Ini ", "teks ", "yang ", "dibuat ", "terpisah.";


Fungsi echo() tidak akan mengembalikan apa-apa setelah dieksekusi. Dia hanya bertugas menampilkan teks saja.
Fungsi print()

Fungsi print() sama seperti fungsi echo(). Dia juga digunakan untuk menampilkan teks ke layar. Fungsi print() juga bisa digunakan tanpa tanda kurung.

Perbedaannya dengan echo():

Fungsi print() akan selalu mengembalikan nilai 1 saat dieksekusi, sedangkan echo() tidak mengembalikan apa-apa.
Fungsi print() hanya boleh diberikan satu parameter saja, sedangkan echo() boleh lebih dari satu.

Apabila kita membuat variabel lalu mengisinya dengan fungsi print() seperti ini:

$cetak = print(“Hello World!”);

Maka variabel $cetak akan bernilai 1.

Apabila kita memberikan dua paramater ke dalam fungsi print(), maka akan terjadi error.

print(“Hello”, “World”); // <– ini akan error

Aplikasi Payroll

Aplikasi payroll adalah modul software untuk melakukan management pembayaran gaji karyawan. Aplikasi ini berbasis web, sehingga membutuhkan webserver untuk instalasinya Read more

Aplikasi Medical Check Up

Aplikasi Medical Check Up Aplikasi Medical Check Up Untuk Klinik atau Rumah Sakit Aplikasi medical check up adalah aplikasi yang Read more

Aplikasi Penjualan Obat Apotik berbasis website

Aplikasi Penjualan Obat Apotik berbasis website Membuat Aplikasi Penjualan Obat Apotik berbasis website dengan bahasa pemrograman PHP. Rancang bangun pembuatan Read more

Aplikasi Penjualan Barang dengan HP dan Printer Bluetooth

Aplikasi Penjualan Barang dengan HP dan Printer Bluetooth Aplikasi Penjualan Barang dengan HP dan Printer Bluetooth – Aplikasi ini berjalan Read more

163 Replies to “Belajar PHP: Perbedaan Fungsi echo(), print(), dan printf() pada PHP”

  1. Amoxicillin For Fish Price

  2. payprox says: – hair loss propecia

  3. Viagra says:

    Prix Kamagra Marseille

  4. Propecia says:

    Zithromax High Dose

  5. icocouche says: – which is best viagra or cialis

  6. payprox says: – finasteride generic uk

  7. Cialis says:

    Kamagra Bijwerkingen

  8. viagra en la farmacia sin receta

  9. Propecia says:

    Propecia Minoxidil Nisim

  10. rurcild says: – how long does it take plaquenil to work for lupus

  11. Priligy says:

    Clomid Glucophage Effets Secondaires

  12. Viagra Generika Ohne Rezept

  13. obtaict says: – how to take lasix to lose water weight

  14. Lasix says:

    Viagra Cialis Einnahme

  15. Fruclip says: – priligy premature ejaculation pills

  16. Priligy says:

    Priligy Sin Receta Espana

  17. lasix shop says:

    Amoxicillin Before Lying Down

  18. Zithromax says:

    Sildenafil 100mg 30 Pills

  19. Fruclip says: – priligy 60 mg price

  20. Prednisone says:

    Buying Discount Stendra

  21. PaysfuG says: – gabapentin withdrawal symptoms

  22. Can Amoxicillin Cure Blackheads

  23. Neurontine says:

    Long Term Effects Of Prednisone

  24. PaysfuG says: – gabapentin used for

  25. Hi there everyone, it’s my first pay a visit at this website, and piece of writing is in fact fruitful in favor of me, keep up posting these articles or reviews.|

  26. Simply wish to say your article is as amazing. The clearness on your submit is just great and i could assume you are a professional in this subject. Well along with your permission allow me to snatch your RSS feed to stay up to date with impending post. Thanks 1,000,000 and please keep up the gratifying work.|

  27. Hello there! This post could not be written any better! Looking through this post reminds me of my previous roommate! He always kept preaching about this. I am going to send this post to him. Pretty sure he’s going to have a good read. Thank you for sharing!|

  28. Cialis says:

    Cialis Echtheit Prufen

  29. Every weekend i used to pay a visit this site, because i wish for enjoyment, for the reason that this this site conations really pleasant funny stuff too.|

  30. Stromectol says:

    Fedex Provera Us Overnight Shipping C.O.D. Online

  31. Morton Mahe says:

    I’m curious to find out what blog platform you have been using? I’m experiencing some small security issues with my latest site and I would like to find something more risk-free. Do you have any recommendations?|

  32. Thanks for finally writing about > blog_title < Loved it!|

  33. Buy Propecia Online India

  34. Propecia says:

    Kamagra 100mg Amiens

  35. lasix dosing says:

    ou acheter cialis en confiance

  36. Viagra Achat Ligne Belgique

  37. Propecia says:

    cialis typical dosage

  38. Lasix says:

    Levitra Experience

  39. Priligy says:

    Achat De Pilule Cialis

  40. Prednisone says:

    Lasix Drug Interaction

  41. Viagra says:

    Protocole Baclofene Ameisen

  42. Plaqdfdf says:

    buy hydroxychloroquine sulfate plaquenil

  43. Plaqdfdf says:

    hydroxychloroquine plaquenil 200 mg tablet buy hydroxychloroquine

  44. CialisTy says:

    viagra vs cialis which is better cialis legal purchase

  45. CialisTy says:

    how to buy cialis online from canada cialis uk supplier

  46. CialisTy says:

    how much does cialis cost without insurance cialis black 800mg reviews

  47. CialisTy says:

    how much does cialis cost at walmart generic cialis 20 mg

  48. CialisTy says:

    viagra levitra cialis which works better? generic cialis usps priority mail

  49. Prednisone says:

    Propecia Pseudoginecomastia

  50. Stromectol says:

    ivermectin brand ivermectin cream uk ivermectin iv
    ivermectin cream uk

  51. Stromectol says:

    ivermectin 8000 ivermectin generic name stromectol usa
    stromectol ivermectin

  52. Stromectol says:

    stromectol 3 mg tablets price ivermectin pills human ivermectin for sale
    ivermectin 50

  53. Stromectol says:

    ivermectin canada stromectol 3mg ivermectin where to buy for humans
    buy stromectol pills

  54. Stromectol says:

    stromectol 12mg ivermectin 1 cream stromectol for humans
    ivermectin 1 cream 45gm

  55. Stromectol says:

    can you buy stromectol over the counter stromectol covid buy ivermectin canada
    ivermectin uk

  56. Sildenafil says:

    viagra without a doctor prescription usa canadian viagra

  57. Sildenafil says:

    real viagra without a doctor prescription buy generic viagra online

  58. Sildenafil says:

    buy viagra online without a prescription cost of viagra

  59. EXPITEGIC says:

    acheter cialis quebec cialis dosage

  60. EXPITEGIC says:

    Cephalexin Dog Reaction cialis generic buy

  61. Wonderful, what a blog it is! This website provides useful data to us, keep it up.|

  62. I just couldn’t depart your website before suggesting that I actually loved the standard info a person provide for your guests? Is gonna be again ceaselessly to investigate cross-check new posts|

Leave a Reply

Your email address will not be published.