PHP - Creating Your Own Functions

Introduction

To define a function, use the following syntax:


function myFunc() {
 // (do stuff here)
}

Demo

<?php
         function hello() {
          echo"Hello, world! \n";
         }// w  w w .  j  av a2  s . c  o  m

         // Displays"Hello, world!"

         hello();
?>

Result

Related Topic