Creating Dynamic Functions : Dynamic Function « Functions « PHP






Creating Dynamic Functions

 
<?php

  if ($_GET['go'] == "yes"){
    if ($_GET['loggedin'] == "true"){
      function dosomething (){
        $_GET['loggedin'] = false;
        echo "You have been successfully logged out.<br />";
      }
      
    }
    if ($_GET['loggedin'] == "false"){
      function dosomething (){
        $_GET['loggedin'] = true;
        echo "You have been successfully logged in.<br />";
      }
    }
    
    dosomething();
    
  }
  
  if ($_GET['loggedin']){
    ?><a href="index.php?go=yes&amp;loggedin=true">click here to log out</a><?php
  } elseif (!$_GET['loggedin']){
    ?><a href="index.php?go=yes&amp;loggedin=false">click here to log in</a><?php
  }
?>
  
  








Related examples in the same category

1.Calling Functions Dynamically
2.Calling a Function Dynamically
3.Calling Variable Functions
4.Calling a Function Dynamically
5.return the function name from a function call or calculation
6.Variable function example
7.Variable Function Names
8.Using a variable function determined by some input variable
9.String Manipulation
10.Using Arrays of Lambda Functions