Guest JesusOnline Posted January 25, 2008 Report Share Posted January 25, 2008 (edited) Kādu laiciņu neesmu ar php darbojies, bet agrāk šāda veida skripts agrāk strādāja ļoti labi skiet uz php4. Šķiet ka visa problēma ir $PHP_SELF, bet nu nesanāk atrast alternatīvu. Varbūt kāds var palīdzēt, kādu hint, vai sampli izmest <?php echo "<table width=750 cellpadding=0 cellspacing=0 align=center><tr><td colspan=3></td></tr> <tr><td width='128' valign='top' class='content'> <a href='$PHP_SELF?action=artist'>edit artists</a><br> <a href='$PHP_SELF?action=album'>edit albums</a><br> <a href='$PHP_SELF?action=song'>edit songs</a><br> </td> <td width='30'> </td> <td width='584' class='content'>"; if($action=="artist") include "artist.php"; elseif($action=="album") include "album.php"; elseif($action=="song") include "song.php"; if(isset($action)) echo "<br><br>"; echo "</td></tr><tr><td colspan=3></td></tr></table>"; ?> Edited January 25, 2008 by JesusOnline Link to comment Share on other sites More sharing options...
andrisp Posted January 25, 2008 Report Share Posted January 25, 2008 Man liekas, bija $_SERVER['PHP_SELF']. Link to comment Share on other sites More sharing options...
Vebers Posted January 25, 2008 Report Share Posted January 25, 2008 Iepriekš kad tev tas strādāja uz servera register_globals bija on, bet tagad ir off, tāpēc nestrādā. Un nav ne smuki, ne droši kodēt ar register_globals on tāpēc labāk izmantot šādu piegājienu: $_SERVER['PHP_SELF'] Link to comment Share on other sites More sharing options...
Guest JesusOnline Posted January 25, 2008 Report Share Posted January 25, 2008 paldies, turpināšu rakt, jo cik palasijos, tad find and replace nepietiks :) Link to comment Share on other sites More sharing options...
marcis Posted January 25, 2008 Report Share Posted January 25, 2008 JesusOnline, Vebers jau atbildēja (protams ne 100%). Tev netikai $_SERVER ir ar globāļiem, bet arī $_GET. Aizvieto $PHP_SELF as $_SERVER['PHP_SELF'] un $action ar $_GET['action']; P.S. Iesaku palasīt par optimizāciju. Link to comment Share on other sites More sharing options...
andrisp Posted January 25, 2008 Report Share Posted January 25, 2008 marcis, kas tad šajā skriptā tāds baigi optimizējams ? Link to comment Share on other sites More sharing options...
Paulinjsh Posted January 25, 2008 Report Share Posted January 25, 2008 arī nedomāju, ka te ir nepieciešama uber optimizācija - tikai parasts replace Link to comment Share on other sites More sharing options...
Aleksejs Posted January 25, 2008 Report Share Posted January 25, 2008 Nu, varbūt tos ifus var ar switch { case... case} aizvietot, bet tas jau vairāk gaumes jautājums laikam... Link to comment Share on other sites More sharing options...
andrisp Posted January 25, 2008 Report Share Posted January 25, 2008 Aleksejs, un tik un tā tā nebus optimizācija. Link to comment Share on other sites More sharing options...
Paulinjsh Posted January 25, 2008 Report Share Posted January 25, 2008 tā būs koda sakārtošana Link to comment Share on other sites More sharing options...
marcis Posted January 26, 2008 Report Share Posted January 26, 2008 Ar optimizāciju es domāju "bla bla $mainigais bla bla" --> 'bla bla '.$mainigais.' bla bla' Link to comment Share on other sites More sharing options...
andrisp Posted January 26, 2008 Report Share Posted January 26, 2008 Kaut gan es arī labāk dodu priekšroku otram variantam, ieguvums ātrdarbībā ir tikai ļoti teorētisks. Link to comment Share on other sites More sharing options...
Kavacky Posted January 26, 2008 Report Share Posted January 26, 2008 echo 'blablabla', $alb, 'blablabla'; Link to comment Share on other sites More sharing options...
Guest JesusOnline Posted February 6, 2008 Report Share Posted February 6, 2008 Lai būtu finālā kāda skaidrība galarezultātā sanāca šādi un darbojas ar register_globals=off: vienkārši un bezkādien php_self <a href="?">Home</a> <a href="?page=about">About</a> <a href="?page=products">Products</a> <a href="?page=contact">Contact</a> <?php switch($_GET['page']) { case "about": echo "About"; break; case "products": echo "Products"; break; case "contact": echo "Contact"; break; default: echo "Home"; break; } ?> pagrābts no http://www.phpmac.com/articles.php?view=241 Link to comment Share on other sites More sharing options...
Recommended Posts