Learn How To Close A PHP Tag Inside A PHP Function

admin_img Posted By Bajarangi soft , Posted On 16-09-2020

In General , whitespace  is not visible on the screen, including spaces, tabs, and end-of-line characters i.e. carrige returns. In PHP whitespace does not matter in coding. You can brake a single line statement to any number of lines or number of separate statement togather on a single line.

Close php tag inside function

First Need to Create Function:
1.Create Function:
function info($name, $email){
    echo "$name <br />";
    echo "$email";
}

Example 1.
<?php
function info($name, $email){
    echo "$name <br />";
    echo "$email";
}
info("Admin", "admin@gmail.com");

?>

Example 2:

 

<?php
function employee_info($employee_name, $salary, $gender)
{
    echo "Employee_Name : $employee_name <br />";
    echo "Salary : $salary <br /> Gender. $gender";
}
employee_info("Jone", "15000", "Male")
?>

 


Complete Code of close php tag inside Function:
<!DOCTYPE html>
<html lang="en">
<head>
    <title>PHP string replace function</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
    <div class="text-center">
        <h1>Is it okay to close a PHP tag inside a function?</h1>
    </div>
    <br>
    <h3>Example 1:</h3>
    <div class="well">
        <?php
        function info($name, $email){
            echo "$name <br />";
            echo "$email";
        }
        info("Admin", "admin@gmail.com");

        ?>
    </div>
    <h3>Example 2:</h3>
    <div class="well">
        <?php
        function employee_info($employee_name, $salary, $gender)
        {
            echo "Employee_Name : $employee_name <br />";
            echo "Salary : $salary <br /> Gender. $gender";
        }
        employee_info("Jone", "15000", "Male")
        ?>
    </div>
    <br>
</div>
</body>
</html>

Related Post