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

    Problema con definizione di una proprietà

    Il codice qui sotto mi genera questo errore:
    Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /membri/marioierardi/engine.php on line 100
    Ho controllato un sacco di volte ma non capisco dove ho sbagliato.
    Ho provato a spostare le proprietà dopo i metodi e lo stesso errore si verifica sul primo metodo dopo il costruttore.
    P.S.
    La riga 100 e quella contenente la prima proprietà della classe Page: "private $path;"
    Help!
    Codice PHP:
    <?php 
        
    include_once 'engine_resources/codes.php'
        
    $pagePath verifyRequest(); 
        
    $page = new Page($pagePath); 
         
        function 
    verifyFirstLevelRequest($path
        { 
            
    $firstLevPath $path
            
    /*Concateno con la cartella e procedo a verifica*/ 
             
            
    foreach($_GET as $key=>$index
            { 
                if(
    is_dir($firstLevPath.$key)!==FALSE
                {     
                    
    $firstLevPath.=$key
                } 
            } 
             
            if(
    $firstLevPath==$path
            { 
                return 
    REQUESTED_INEXISTENT_PAGE;/*La cartella non esiste per il percorso specificato*/ 
            

             
            return 
    verifyPageTree($firstLevPath); 
        } 
         
        function 
    verifySecondLevelRequest($path
        { 
            
    $secondLevelPath ""
            if((
    $firstLevelPath verifyFirstLevelRequest($path))!=FALSE
            { 
                
    /*Concateno con la sottocartella e procedo a verifica*/ 
                
    $subDir $firstLevelPath
                
    str_replace($path,'',$subDir);/*Cancella il percorso lasciando solo il nome*/ 
                
    $secondLevelPath.=$firstLevelPath.'/'.$_GET[$subDir]; 
                 
                if(!
    is_dir($secondLevelPath)) 
                { 
                    return 
    REQUESTED_INEXISTENT_PAGE;/*La cartella non esiste per il percorso specificato*/ 
                

                 
                return 
    verifyPageTree($secondLevelPath); 
            } 
        } 
         
        function 
    verifyPageTree($path
        { 
            
    /*Verifica basilare di integrità dell'albero della pagina richiesta*/ 
             
            
    $childrenRequired = array("/subpages/","content.php","include_apps","meta","style.css"); 
             
            
    $pagePath $path
            if((
    $pageResorce opendir($pagePath))!==FALSE
            { 
                
    $childrenExisting = array(); 
                while((
    $subFile readdir($pageResorce)) !== FALSE
                { 
                    
    array_push($childrenExisting,$subFile); 
                } 
                
    closedir(); 
                 
                if(
    $childrenRequired==$childrenExisting
                { 
                    
    /*Integrità confermata*/ 
                    
    return pagePath
                }else{ 
                    return 
    REQUESTED_INEXISTENT_PAGE;/*Integrità non confermata*/ 
                

            }else{ 
                return 
    REQUESTED_INEXISTENT_PAGE;/*Cartella inaccessibile*/ 
            

        } 
         
        function 
    verifyRequest() 
        { 
            
    $pagesPath $_SERVER['DOCUMENT_ROOT'].'/pages/'
             
            if(
    $_SERVER['REQUEST_METHOD'] == 'GET'
            { 
                
    $sog=sizeof($_GET); 
                if(
    $sog>1
                { 
                    return 
    REQUESTED_INEXISTENT_PAGE
                }elseif(
    $sog==1
                { 
                    if(empty(
    $_GET[0])) 
                    { 
                        return 
    verifyFirstLevelRequest($pagesPath); 
                    }else 
                    { 
                        return 
    verifySecondLevelRequest($pagesPath); 
                    } 
                } 
            }else{ 
                return 
    REQUESTED_DEFAULT_PAGE
            } 
        } 
         
        class 
    Page{     
            private 
    $path
            private 
    $meta
            private 
    $headerApps
            private 
    $bodyApps
            private 
    $css
            private 
    $subPagesReferences = array();/*Carichiamo solo alcuni dati, utili alla navigazione, delle sottocategorie della pagina*/ 
         
            
    function __construct($requestSubject){ 
                
    $this->parseRequest($requestSubject); /*Fatto*/ 
                
    $this->getCSS(); 
                
    $this->getMeta(); /*Fatto*/ 
                
    $this->getApps(); /*Fatto*/ 
                
    $this->getSubPagesRef(); 
            } 
             
            private function 
    getMeta(){ 
                
    $rawData $this->getByFile($this->path.'meta'); 
                
    $metalist explode(';',$rawData); 
                foreach(
    $metalist as $value
                { 
                    
    $tmp explode('=',$value); 
                    
    $formatted '<meta name="'.$tmp[0].'" content="'.$tmp[1].'"/>'
                    
    $this->meta.=$formatted
                }         
            } 
             
            private function 
    getApps(){ 
                
    $localApps $this->getLocalApps(); 
                
    $formatted=''
                
    $rawData $this->getByFile($this->path.'include_apps'); 
                
    $applist explode(';',$rawData); 
                foreach(
    $applist as $value
                { 
                    if(
    substr($value,0,11)=='external://'
                    { 
                        
    $formatted '<script language="javascript" type="text/javascript" src="'.substr($value,11).'"></script>'
                        
    $headerApps.=$formatted;/*I link esterni evngono messi per default nella testata*/ 
                    
    }else{ 
                        if((
    $appIndex array_search($value$localApps)) != FALSE
                        { 
                            
    $formatted '<script language="javascript" type="text/javascript" src="'.$localApps[0].$localApps[1].'"></script>'
                            if(
    $localApps[0]=='/apps/head/'
                            { 
                                
    $headerApps.=$formatted
                            }else{ 
                                
    $bodyApps.=$formatted
                            } 
                        } 
                    } 
                } 
            } 
             
            private function 
    getLocalApps(){ 
                
    $localAppList = array(); 
                
    $bodyAppPath 'apps/body/'
                
    $headAppPath 'apps/head/'
                
    $pageResorce opendir($bodyAppPath) or die('impossibile aprire la cartella!'); 
                while((
    $file readdir($pageResorce)) !== FALSE
                { 
                    
    array_push($localAppList,array($file,$bodyAppPath)); 
                } 
                
    closedir(); 
                
    $pageResorce opendir($headAppPath) or die('impossibile aprire la cartella!'); 
                while((
    $file readdir($pageResorce)) !== FALSE
                { 
                    
    array_push($localAppList,array($headAppPath,$file)); 
                } 
                
    closedir(); 
                return 
    $localAppList
            } 
             
            private function 
    getCSS(){ 
                 
            } 
             
            private function 
    getSubPagesRef(){ 
                 
            } 
             
            private function 
    parseRequest($subject){ 
                
    $requestPath $subject
                if(
    $requestPath==REQUESTED_DEFAULT_PAGE
                {     
                    
    $requestPath=$_SERVER['DOCUMENT_ROOT'].'/pages/home/'
                }elseif(
    $requestPath==REQUESTED_INEXISTENT_PAGE
                { 
                    
    $requestPath=$_SERVER['DOCUMENT_ROOT'].'/pages/pagenotfound/'
                } 
                 
                
    $this->path=$requestPath
            } 
             
            private function 
    getByFile($path){ 
                
    $text ""
                
    $fp fopen($path,'r') or die('Impossibile aprire il file!'); 
                 
                while((
    $line fgets($fp))!== FALSE
                { 
                    
    $text.=$line
                } 
                return 
    $text
            } 
             
            function 
    printDocTitle(){ 
                print 
    "Mio titolo"
            } 
             
            function 
    printMetaTags(){ 
                print 
    $this->meta
            } 
             
            function 
    printHeaderApps(){ 
                print 
    $this->headerApps
            } 
             
            function 
    printCSS(){ 
                print 
    $this->css
            } 
             
            function 
    printBodyHeader(){ 
                include_once 
    'shared_content/header.php'
            } 
             
            function 
    printBodyContent(){ 
                include_once 
    $this->path.'/content.php'
            } 
             
            function 
    printBodyFooter(){ 
                include_once 
    'shared_content/footer.php'
            } 
             
            function 
    printBodyApps(){ 
                print 
    $this->bodyApps
            }         
        }; 
    ?>
    Più calmo diventi, più puoi udire

  2. #2
    Ciao,
    che versione di php c'è sul server dove stai provando lo script?
    Full Stack Developer presso Advice Lab
    Bonus Bitcoin
    Moon Bitcoin

  3. #3
    Grazie della risposta.
    Sono server di altervista. Sto cercando anch'io di sapere che versione abbiano.
    Anche perchè l'errore non si verifica in locale su EasyPHP5.4
    Più calmo diventi, più puoi udire

  4. #4
    Allora è la versione di php. Fai un phpinfo() per vedere che versione c'è.
    Se hai php4 cambiano alcune cose, ad esempio il costruttore della class deve avere il nome della classe stessa... non puoi usare public/private per le funzioni.. etc..

    ADD:
    Se non ricordo male cmq, su altervista dovresti avere la possibilità di usare anche php5.
    Come al momento non me lo ricordo, prova a cercare nel pannello di admin, o tra le loro faq
    Full Stack Developer presso Advice Lab
    Bonus Bitcoin
    Moon Bitcoin

  5. #5
    Versione su altervista: 4.4.9
    Modo per risolverla, tratta da una ricerca su altervista sotto tuo consiglio:

    accedere alle impostazioni del file .htaccess (presente all'interno della sezione 'gesione file') e tra le opzioni disponibili modificare:
    "Scegli la versione di PHP da usare" portando "Attiva supporto php5 (off = php4)" da off a on.

    grazie mille per i consigli.
    Più calmo diventi, più puoi udire

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.