Palabras Reservadas En Php

Páginas: 6 (1448 palabras) Publicado: 18 de junio de 2015
Palabras reservadas en php:
(PHP 5 >= 5.1.0)
1)__halt_compiler: — Detiene la ejecución del compilador
Descripción ¶
void __halt_compiler ( void )
Detiene la ejecución del compilador. Esto puede ser útil para embeber información en scripts de PHP, como en archivos de instalación.
La posición de byte del inicio de la información se puede determinar por la constante__COMPILER_HALT_OFFSET__, la cuálestá definida sólo si hay un __halt_compiler() presente en el archivo.

No devuelve ningún valor.
Ejemplos ¶
Ejemplo #1 Un Ejemplo de __halt_compiler()

// abrir este archivo
$fp = fopen(__FILE__, 'r');

// buscar el puntero de archivo a la información
fseek($fp, __COMPILER_HALT_OFFSET__);

// e imprimirlo
var_dump(stream_get_contents($fp));

// el final de la ejecución del script__halt_compiler(); la información de instalación (p.ej. tar, gz, PHP, etc.)
Notas ¶
Nota:
__halt_compiler() sólo se puede usar desde el ámbito más externo.
 add a note
User Contributed Notes 8 notes
up
down
17
-T- ¶
1 year ago
What zsh mentioned six years ago: "Also, it cannot be used in eval() -- it won't throw a syntax error, but it won't do anything either." is wrong. It can be used in eval() -- it willhalt the eval.
up
down
2
joey at gimo dot co dot uk ¶
1 year ago
I don't exactly know what PHP is doing internally but I don't understand the sanity behind how in token_get_all __halt_compiler is handled.

This is actually valid there:
__halt_compiler/**/ /**/ /**/ /**/ /** */();raw

Normally it pops off just any three tokens so you can have even __halt_compiler***, __halt_compiler))), etc intoken _get all.

The weird thing is that is also skips T_OPEN_TAG but in the context __halt_compiler runs in this tag should not be posible. Instead it will pick up < and ? as operators and php as a T_STRING.

It ignores the token at any point so this is also valid:
__halt_compiler()/**/ /**/ /**/ /**/ /** */;raw

When I test this with a php file rather than the tokeniser it works the same.

I canonly conclude that PHP/__halt_compiler is pretty weird.

I think this is from attempting to weakly imitate the same syntax handling as in functions (I guess you can put comments/whitespace anywhere). I find it annoying and counter productive though.

Even this is valid:
__halt_compiler// comment\n();raw

A general problem that compound matters is that tokenise wont check whether or not syntax isvalid (tokens against each other). When running as PHP you must have ();.
up
down
5
ravenswd at gmail dot com ¶
4 years ago
__halt_compiler is also useful for debugging. If you need to temporarily make a change that will introduce an error later on, use __halt_compiler to prevent syntax errors. For example:

if ( $something ):
  print 'something';
endif;   // endif placed here for debuggingpurposes
__halt_compiler();
endif;   // original location of endif -- would produce syntax error if __halt_compiler was not there
?>
up
down
1
cwk32 at mail dot ustc dot edu dot cn ¶
3 months ago
if you find the value of __COMPILER_HALT_OFFSET__ is highly strange. Maybe...

there are some complier optimization tools, like eAccelator(very old). When the program is pre-complied and cached, the__COMPILER_HALT_OFFSET__ will be 0 = =
up
down
0
Krzysiek ¶
10 months ago
Joey, you're wrong saying that __halt_compiler have strange behavior. This structure works exactly the same as any other build in structure like empty or isset (even similarly to functions; at least in tokenizer level).

About T_OPEN_TAG - after one open tag is present you didn't expect other one in current php code section, sotokenizer try to handle this "thing" in other way and it's perfectly normal...
up
down
-4

2) break :
(PHP 4, PHP 5)
break termina la ejecución de la estructura actual for, foreach, while, do-while o switch.
break acepta un argumento numérico opcional el cual indica de cuantas estructuras anidadas encerradas se debe salir.

3) Clonación de Objetos:
No siempre se desea crear una copia de un objeto...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Palabras reservadas de c,php,.net, otros
  • Palabras reservadas
  • Palabras Reservadas
  • Palabras reservadas
  • palabras reservadas
  • Palabras reservadas
  • Palabras Reservadas De Java
  • Palabras Reservadas en Java

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS