Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Feb 2004
    Messaggi
    191

    Spiegazioni Funzioni variablili

    Salve, ho bisogno che qualche anima pia mi spieghi quest'esercizio.
    Ok per la prima funzione che si richiama con apples()

    Codice PHP:
    <?php
    $function_variable 
    "apples";
    $function_variable();       
     
    $function_variable "oranges";
    $function_variable("In oranges() now."); 
     
    $function_variable "bananas";
    $function_variable("In bananas() now."); 
     
    function 
    apples()
       {
          echo 
    "In apples() now.
    "
    ;
          echo 
    "We have plenty of apples.

    "
    ;
       }
     
    function 
    oranges($argument)
       {
          echo 
    "$argument 
    "
    ;
          
    "We have plenty of oranges also.

    "
    ;
       }
     
    function 
    bananas($argument="")
       {
          echo 
    "$argument 
    "
    ;
          echo 
    "Well stocked on bananas too.

    "
    ;
       }
    ?>

  2. #2
    http://www.php.net/manual/en/functio...-functions.php

    PHP supports the concept of variable functions. This means that if a variable name has parentheses appended to it, PHP will look for a function with the same name as whatever the variable evaluates to, and will attempt to execute it.
    In pratica $function_variable(); significa, esegui la funzione il cui nome e' contenuto nella variabile $function_variable.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.