Chrome Extension

Create function in PHP

<?php
    function greeting($username) {
        echo "Hello : " . $username;
    }

    greeting("John");
?>
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool
Output
Hello : John

To create a function in PHP simply add function keyword before function name and write code inside its code block. You can run a chunk of code using the PHP function and define as many functions as you want inside the PHP script.

You can also pass parameters to a function and can retrieve that parameter by its name inside the function.

Was this helpful?
0 Comments