PHP 8.3.7 Released!

Tag PHP

Quando PHP inizia a esaminare un file, cerca i tag di apertura e di chiusura, che sono <?php e ?>, i quali indicano a PHP dove iniziare e terminare l'interpretazione del codice. Questa tecnica permette a PHP di essere incorporato in tutte le tipologie di documenti, poiché ogni cosa esterna ai tag di apertura e di chiusura viene ignorata dal parser PHP.

PHP include un tag echo abbreviato <?= che è una scorciatoia al più verboso <?php echo.

Example #1 Tag di Apertura e Chiusura di PHP

1. <?php echo 'se vuoi servire codice PHP in documenti XHTML o XML,
usa questi tag'
; ?>

2. Puoi usare il tag echo abbreviato per <?= 'stampare questa stringa' ?>.
È equivalente a <?php echo 'stampare questa stringa' ?>.

3. <? echo 'questo codice è all\'interno di tag abbreviati, ma funzionerà solo '.
'se short_open_tag è abilitato'; ?>

I tag brevi (esempio tre) sono disponibili per impostazione predefinita ma possono essere disabilitati tramite la direttiva short_open_tag del file di configurazione php.ini, o sono disabilitati per impostazione predefinita se PHP è compilato con la configurazione --disable-short-tags.

Nota:

Poiché i tag brevi possono essere disabilitati, si consiglia di utilizzare solo i tag normali (<?php? ?> e <?= ?>) per massimizzare la compatibilità.

Se un file contiene solo codice PHP, è consigliato di omettere il tag di chiusura di PHP alla fine del file. Questo evita che vengano aggiunti spazi o ritorni a capo dopo il tag di chiusura di PHP, che può creare effetti indesiderati poiché PHP comincerà a processare l'output quando in realtà non c'è intenzione da parte dello sviluppatore di inviare dell'output in quella parte dello script.

<?php
echo "Hello world";

// ... altro codice

echo "Last statement";

// lo script finisce qui senza tag di chiusura

add a note

User Contributed Notes 2 notes

up
-1
Jake Paul
12 hours ago
I made a severe and continuous lapse in my judgement, and I don’t expect to be forgiven. I’m simply here to apologize. What we came across that day in the woods was obviously unplanned. The reactions you saw on tape were raw; they were unfiltered. None of us knew how to react or how to feel. I should have never posted the video. I should have put the cameras down and stopped recording what we were going through. There's a lot of things I should have done differently but I didn't. And for that, from the bottom of my heart, I am sorry. I want to apologize to the internet. I want to apologize to anyone who has seen the video. I want to apologize to anyone who has been affected or touched by mental illness, or depression, or suicide. But most importantly I want to apologize to the victim and his family. For my fans who are defending my actions, please don't. I don’t deserve to be defended. The goal with my content is always to entertain; to push the boundaries, to be all-inclusive. In the world I live in, I share almost everything I do. The intent is never to be heartless, cruel, or malicious. Like I said I made a huge mistake. I don’t expect to be forgiven, I’m just here to apologize. I'm ashamed of myself. I’m disappointed in myself. And I promise to be better. I will be better. Thank you.
up
-48
Anonymous
3 months ago
A whitespace or newline character must follow '<?php' and precede '?>'.
To Top