CakeFest 2024: The Official CakePHP Conference

Örnekler

Burada simgeleştiriciyi kullanan basit PHP betiğine yer verilmişir. Betik bir PHP dosyasını okumakta, açıklamaları ayıklayıp salt PHP kodunu çıktılamaktadır.

Örnek 1 - Açıklamaları simgeleştirici ile ayıklamak

<?php
$source
= file_get_contents('example.php');
$tokens = token_get_all($source);

foreach (
$tokens as $token) {
if (
is_string($token)) {
// basit tek karakterlik dizgecik
echo $token;
} else {
// dizgecik dizisi
list($id, $text) = $token;

switch (
$id) {
case
T_COMMENT:
case
T_DOC_COMMENT: // bunu
// açıklamalar üzerinde işlem yapmamak için tanımladık
break;

default:
// Kalan herşey "olduğu gibi" çıktılanacak
echo $text;
break;
}
}
}
?>
add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top