Visualizzazione dei risultati da 1 a 4 su 4
  1. #1

    [php]Classe generatore_form errore

    Spero di non essere diventato orbo/cieco io ma nel codice qui sotto, mi viene segnalato un'errore che non mi sembra di vederlo

    Codice PHP:
    class oggetti_form {

        var 
    $label;
        var 
    $name;
        var 
    $style;

        function 
    oggetti_form($label$name$style) {
            (!
    is_numeric($label)) ? $this->label $label : die('Hai passato un parametro non valido: ' $label);
            (!
    is_numeric($name)) ? $this->name $name : die('Hai passato un parametro non valido: ' $name);
            (!
    is_numeric($stile)) ? $this->style $style : die('Hai passato un parametro non valido: ' $style);
        }

        function 
    genera_form() {
            echo 
    'Questo metodo verrà sovrascritto dagli altri';
        }
    }

    /** Definizione della classe per l'oggetto input di testo **/
    class input_testo extends oggetti_form {

        var 
    $value;
        var 
    $maxlenght;

        function 
    input_testo($label$name$style$value$maxlenght) {
            
    parent::oggetti_form($label$name$style);
            (!
    is_numeric($value)) ? $this->value $value : die('Parametro non valido: ' $value);
            (
    is_int($maxlenght) && $maxlenght && $maxlenght 30) ? $this->maxlenght $maxlenght : die('Parametro non valido: ' $maxlenght);
        }

        function 
    genera_form() {
            
    $html $this->label '<input type="text" name="' $this->name '" value="' $this->value '" class="' $this->style '" maxlenght="' $this->maxlenght "\" />\n";
            return 
    $html;
        }

    La riga incriminata è:
    Codice PHP:
    $html $this->label '<input type="text" name="' $this->name '" value="' $this->value '" class="' $this->style '" maxlenght="' $this->maxlenght "\" />\n"
    e mi dice unexpected T_VARIABLE in ............quella riga li.......

    Ah spero non c'entri qualcosa il fatto che scrivo codice php4 su un server aggiornato a php5 questa semplice classe dovrebbe essere riconosciuta lo stesso..

    Ci vedete meglio di me?? :master:
    Questa volta, più che un voto.. è favoreggiamento.

  2. #2
    maxlenght="' . $this->maxlenght . "

    Ci manca l'apice singolo

  3. #3
    No, ho usato l'apice doppio appositamente per non dover scrivere:

    Codice PHP:
    maxlenght="' . $this->maxlenght . '" />' . "\n"; 
    Questa volta, più che un voto.. è favoreggiamento.

  4. #4
    Minghiaaaaaa mancava un punto..

    Ottimo risolto
    Questa volta, più che un voto.. è favoreggiamento.

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.