Get Smarty

Donate

Paypal

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Sites Using Smarty

Advertisement

Chapter 17. Localização de Erros

Table of Contents

Erros do Smarty/PHP

Erros do Smarty/PHP

O Smarty pode obter muitos erros, tais como: atributos de tags perdidos ou nomes de variáveis mal formadas. Se isto acontece, você verá um erro similar ao seguir:

Example 17.1. Erros do Smarty

Warning: Smarty: [in index.tpl line 4]: syntax error: unknown tag - '%blah'
        in /path/to/smarty/Smarty.class.php on line 1041

Fatal error: Smarty: [in index.tpl line 28]: syntax error: missing section name
        in /path/to/smarty/Smarty.class.php on line 1041

O Smarty te mostra o nome do template, o número da linha e o erro. Depois disso, o erro consiste do número da linha da classe Smarty em que o erro ocorreu.

Há certos erros que o Smarty não consegue detectar, tais como uma tag de fechamento errada. Estes tipos de erro geralmente acabam gerando erros em tempo de processamento do interpretador de erros do PHP.

Example 17.2. Erros de análise do PHP

Parse error: parse error in /path/to/smarty/templates_c/index.tpl.php on line 75

Quando você encontra um erro de análise do PHP, o número da linha do erro corresponderá ao script PHP compilado, não o template em si. Normalmente você pode no template localizar o erro de sintaxe. Aqui algumas coisas para você procurar: falta de fechamento de tags para {if}{/if} ou {section}{/section}, ou erro de lógica dentro de uma tag {if}. Se você não conseguir encontrar o erro, talvez seja necessário abrir o arquivo PHP compilado e ir até o número da linha exibido, para saber onde se encontra o erro correspondente no template.

Example 17.3. Other common errors

  • 
    Warning: Smarty error: unable to read resource: "index.tpl" in...
    or
    Warning: Smarty error: unable to read resource: "site.conf" in...
    
        

    • The $template_dir is incorrect, doesn't exist or the file index.tpl is not in the templates/ directory

    • A {config_load} function is within a template (or config_load() has been called) and either $config_dir is incorrent , does not exist or site.conf is not in the directory.

  • 
    Fatal error: Smarty error: the $compile_dir 'templates_c' does not exist,
    or is not a directory...
    
         

    Either the $compile_dir is incorrectly set, the directory does not exist, or templates_c is a file and not a directory.

  •       
           Fatal error: Smarty error: unable to write to $compile_dir '....
          
         

    The $compile_dir is not writable by the web server. See the bottom of the installing smarty page for permissions.

  • 
    Fatal error: Smarty error: the $cache_dir 'cache' does not exist,
    or is not a directory. in /..
    
       

    This means that $caching is enabled and either; the $cache_dir is incorrectly set, the directory does not exist, or cache is a file and not a directory.

  •                        
                                    Fatal error: Smarty error: unable to write to $cache_dir '/...
                                    
                       

    This means that $caching is enabled and the $cache_dir is not writable by the web server. See the bottom of the installing smarty page for permissions.


See also debugging, $error_reporting and trigger_error().

Comments
No comments for this page.

Advertisement

Sponsors [info]

Sponsors