php işlem dosyasını durdurmak

3 Cevap

Bir dosyayı işleme php stop yapmak ve sadece zaten çözümlü bölümü ile iş yapmak için herhangi bir yolu var mı. Ben böyle demek:

<some data here>
<?php phpinfo(); [IS THERE ANY THING I CAN PUT HERE] ?>
<more data>
[IS THERE ANY THING I CAN PUT HERE]
<?HOW CAN I MAKE PHP NOT PARSE THIS?>

php php ilk bölümünden sonra verileri göz ardı yapmak için yine de var mı?

3 Cevap

Başka bir çözüm kullanmak olabilir __halt_compiler :

Halts the execution of the compiler. This can be useful to embed data in PHP scripts, like the installation files.

Byte position of the data start can be determined by the __COMPILER_HALT_OFFSET__ constant which is defined only if there is a __halt_compiler() presented in the file.

Eğer tek bir dosya içine PHP ve (muhtemelen ikili) veri gömmek için gerektiğinde tipik bir kullanım, Phar archives için, ve PHP kodu bu verilere erişimi olması gerekir.


And there is actually a difference : this code :

blah blah
<?php phpinfo(); ?>
glop glop
<?php exit(); ?>
<?HOW CAN I MAKE PHP NOT PARSE THIS?>

Gets me a Parse error: syntax error, unexpected T_STRING
(Probably because I have short_open_tag enabled, I suppose)


While this one :

blah blah
<?php phpinfo(); ?>
glop glop
<?php __halt_compiler(); ?>
<?HOW CAN I MAKE PHP NOT PARSE THIS?>

Tamam çalışır - bu geçersiz PHP kodu __halt_compiler() için çağrısından sonra olmak.

Siz dosyayı işleme bitirmek için PHP anlatmak için exit anahtar kelime kullanabilirsiniz.

Ben yapmanız gereken tüm return 0; (ya da herhangi başka bir değer), PHP bu dosyayı ayrıştırma durdurmak ve çağrılan ne dönecektir yazmak olduğuna inanıyoruz. Eğer tek bir dosyada yürütülmesine durdurmak gerekir ama die() veya exit() tamamen istemez yararlıdır.