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";
         }//from   w  ww  .  j a  va 2 s. c  o  m

         // Displays"Hello, world!"

         hello();
?>

Result

Related Topic