Tag
3 Cevap

Birinin bıraktığı bir mirastır kodu ile çalışıyorum ve bu kodu yeniden dağıtmak için görev olur. Windows Server 2003, Apache 2.0.63 ve PHP 5.2.10 kullanıyorum.

Bu çalışmıyor. En azından, bir şekilde ben o iş için bekleniyor değil. Eğer sen, hata diyoruz.

Teftiş üzerine, ben (uygulamada birçok kez görünür) bu kod suçlu olduğuna dair bir şüphe vardı.

    &$this->

Sorunu göstermek için, ben bu kodu yeniden:

    <?php
       phpinfo();
       //$variable = &$this->request;
    ?>

Yukarıdaki kod güzel ve beklendiği gibi idam. Ancak, ben kodunu değiştirmek eğer:

    <?
       phpinfo();
       //$variable = &$this->request;
    ?>

Kod misbehaves, ve bunun yerine ekranda olan tabii ki, tamamen beklenmedik ve istenmeyen bu sonucu.

    request; ?>

Şimdi, kod yukarıdaki gibi bir kod ile doludur ve bu gibi, uygulama şimdi benzer ekranda çıktı üretmek:

    request; $user = &$this->user; // This is comment return false; ?>

gibi okuyan bir kodu:

    <?
        $request = &$this->request;
        $user = &$this->user;
        // This is comment
        return false;
    ?>  

Ben onun çirkin başını rears, ama çoğu zaman, yerine yeni bir hata tanıtır.

Ben, PHP ve Apache yeniden hatta PHP başka bir sürümü (5.2.6) kullanılarak ve hala çalışmaz. Benim localhost (Mac OS X, PHP 5.2.8 ve Apache 2.0.63) kodu dağıtılan ve bir güçlük olmadan çalıştı.

Lütfen, herkes, any aydınlanma daha yeterli olacaktır.

3 Cevap

Php.ini olarak, aşağıdaki yönergeyi ayarlamanız gerekir:

short_open_tag = On

Kimden manual:

Tells whether the short form (<? ?>) of PHP's open tag should be allowed...

Elinizde zaman varsa, tam form olanlardan <?php ile '<?' tüm bu kısa etiketleri yerine düşünebilirsiniz, daha iyi taşınabilirlik için (sadece ne olduğunu görmek sen? :)

my recommendation is not to use open tags, because it can interfere with <?xml codes. I also had that problem before, just go ve replace all <?php to <? , ve then again all <? to <?php.

In this way you won't get any

<?  <-- one space after the '?'

ve

<?php  <-- one space after the 'p'

Bu yardımcı olur umarım ...

If you want to use the short tags: ("<?")

Onlar size php.ini etkin olması gerekiyor. Bu bak link.