Salve, stò imparando a programmare in php e lavorando su uno script del manuale che stò usando(php4) si verifica la seguente situazione:
Il codice dello script:
<?php
session_register("view1count");
session_register("view2count");
session_register("view3count");
session_register("view4count");
?>
<?php
//page_count.php
if (!$view1count) $view1count = 0;
if (!$view2count) $view2count = 0;
if (!$view3count) $view3count = 0;
if (!$view4count) $view4count = 0;
echo "<HTML><HEAD><TITLE>Web Page Hit Counter</TITLE></HEAD><BODY>";
if ($whichpage) {
echo "<B>You are currently on page $whichpage.</B><BR><BR>\n";
$GLOBALS["view${whichpage}count"]++;
}
for ($i = 1; $i <= 4; $i++) {
if ($whichpage == $i) {
echo "<B><A HREF=\"$PHP_SELF?".SID."&whichpage=$i\">Page $i</A></B>";
} else {
echo "<A HREF=\"$PHP_SELF?".SID."&whichpage=$i\">Page $i</A>";
}
echo ", which you have chosen ".$GLOBALS["view${i}count"]." times.<BR>\n";
}
echo "\n\n<BR><BR>\n\n";
echo "</BODY></HTML>";
?>
Lo script funziona ma restituisce i seguenti messaggi di errore:
Deprecated: Function session_register() is deprecated in C:\wamp\www\4\ch08\page_count.php on line 2
Deprecated: Function session_register() is deprecated in C:\wamp\www\4\ch08\page_count.php on line 3
Deprecated: Function session_register() is deprecated in C:\wamp\www\4\ch08\page_count.php on line 4
Deprecated: Function session_register() is deprecated in C:\wamp\www\4\ch08\page_count.php on line 5
Notice: Undefined variable: whichpage in C:\wamp\www\4\ch08\page_count.php on line 18
Notice: Undefined variable: whichpage in C:\wamp\www\4\ch08\page_count.php on line 25
Page 1, which you have chosen 13 times.
Notice: Undefined variable: whichpage in C:\wamp\www\4\ch08\page_count.php on line 25
Page 2, which you have chosen 8 times.
Notice: Undefined variable: whichpage in C:\wamp\www\4\ch08\page_count.php on line 25
Page 3, which you have chosen 5 times.
Notice: Undefined variable: whichpage in C:\wamp\www\4\ch08\page_count.php on line 25
Page 4, which you have chosen 15 times.
Altro script:
<HTML>
<HEAD><TITLE>Hangman</TITLE></HEAD>
<BODY><DIV ALIGN = 'center'>
<?php
//hangman.php
$alphabet = array("A","B","C","D","E","F","G","H","I","J","K","L","M",
"N","O","P","Q","R","S","T","U","V","W","X","Y","Z");
$words = array("AARDVARK", "INDIGESTION", "CALCULATOR",
"PERISTALSIS", "VERMILLION", "MNEMONIC");
$wrong = 0;
if (!isset($word_number)) { $word_number = rand(1,count($words)) - 1; }
echo"<H1>";
$word = $words[$word_number];
$finished = 1;
for ($i=0; $i < strlen($word); $i++) {
if (ereg($word[$i], $letters)) {
echo $word[$i];
}
else {
echo "_";
$finished = 0;
}
}
echo"</H1>";
if ($finished) {
echo "<BR><BR>Congratulations! You win!<BR><BR>";
echo "<A HREF=$PHP_SELF>Play again</A>";
}
else {
foreach ($alphabet as $var) {
if (ereg($var, $letters)) {
if (ereg($var, $words[$word_number])) {
$links .= "<B>$var</B> ";
} else {
$links .= "$var ";
$wrong++;
}
}
else {
$links .= "<A HREF=\"$PHP_SELF?letters=$letters$var&word_number=$word_number\">$var</A> ";
//echo "$letters$var";
}
}
echo "<BR><IMG SRC=\"./hangman$wrong.gif\"><BR>";
if ($wrong == 12) {
echo "<BR>HANGMAN!!<BR><BR>";
echo "The word you were looking for was \"$word\"<BR><BR>";
echo "<A HREF=$PHP_SELF>Play again</A>";
} else {
echo "Tries remaining = ".(12-$wrong)."<BR>";
echo "<BR>Please pick a letter.<BR><BR>";
echo $links;
}
}
?>
</DIV></BODY>
</HTML>
Qui le righe di errore sono molte, ne riporto solo alcune:
Deprecated: Function ereg() is deprecated in C:\wamp\www\4\ch08\hangman.php on line 20
_
Deprecated: Function ereg() is deprecated in C:\wamp\www\4\ch08\hangman.php on line 20
K
Deprecated: Function ereg() is deprecated in C:\wamp\www\4\ch08\hangman.php on line 35
Deprecated: Function ereg() is deprecated in C:\wamp\www\4\ch08\hangman.php on line 36
Notice: Undefined variable: links in C:\wamp\www\4\ch08\hangman.php on line 37
Deprecated: Function ereg() is deprecated in C:\wamp\www\4\ch08\hangman.php on line 35
A momenti mi arriveranno per posta i manuali di php6 ma siccome questo manuale di php 4 è molto buono ho iniziato tuttavia a studiarlo e sono arrivato a metà e ci terrei a capire come far funzionare gli script...Grazie
Il codice dello script:
<?php
session_register("view1count");
session_register("view2count");
session_register("view3count");
session_register("view4count");
?>
<?php
//page_count.php
if (!$view1count) $view1count = 0;
if (!$view2count) $view2count = 0;
if (!$view3count) $view3count = 0;
if (!$view4count) $view4count = 0;
echo "<HTML><HEAD><TITLE>Web Page Hit Counter</TITLE></HEAD><BODY>";
if ($whichpage) {
echo "<B>You are currently on page $whichpage.</B><BR><BR>\n";
$GLOBALS["view${whichpage}count"]++;
}
for ($i = 1; $i <= 4; $i++) {
if ($whichpage == $i) {
echo "<B><A HREF=\"$PHP_SELF?".SID."&whichpage=$i\">Page $i</A></B>";
} else {
echo "<A HREF=\"$PHP_SELF?".SID."&whichpage=$i\">Page $i</A>";
}
echo ", which you have chosen ".$GLOBALS["view${i}count"]." times.<BR>\n";
}
echo "\n\n<BR><BR>\n\n";
echo "</BODY></HTML>";
?>
Lo script funziona ma restituisce i seguenti messaggi di errore:
Deprecated: Function session_register() is deprecated in C:\wamp\www\4\ch08\page_count.php on line 2
Deprecated: Function session_register() is deprecated in C:\wamp\www\4\ch08\page_count.php on line 3
Deprecated: Function session_register() is deprecated in C:\wamp\www\4\ch08\page_count.php on line 4
Deprecated: Function session_register() is deprecated in C:\wamp\www\4\ch08\page_count.php on line 5
Notice: Undefined variable: whichpage in C:\wamp\www\4\ch08\page_count.php on line 18
Notice: Undefined variable: whichpage in C:\wamp\www\4\ch08\page_count.php on line 25
Page 1, which you have chosen 13 times.
Notice: Undefined variable: whichpage in C:\wamp\www\4\ch08\page_count.php on line 25
Page 2, which you have chosen 8 times.
Notice: Undefined variable: whichpage in C:\wamp\www\4\ch08\page_count.php on line 25
Page 3, which you have chosen 5 times.
Notice: Undefined variable: whichpage in C:\wamp\www\4\ch08\page_count.php on line 25
Page 4, which you have chosen 15 times.
Altro script:
<HTML>
<HEAD><TITLE>Hangman</TITLE></HEAD>
<BODY><DIV ALIGN = 'center'>
<?php
//hangman.php
$alphabet = array("A","B","C","D","E","F","G","H","I","J","K","L","M",
"N","O","P","Q","R","S","T","U","V","W","X","Y","Z");
$words = array("AARDVARK", "INDIGESTION", "CALCULATOR",
"PERISTALSIS", "VERMILLION", "MNEMONIC");
$wrong = 0;
if (!isset($word_number)) { $word_number = rand(1,count($words)) - 1; }
echo"<H1>";
$word = $words[$word_number];
$finished = 1;
for ($i=0; $i < strlen($word); $i++) {
if (ereg($word[$i], $letters)) {
echo $word[$i];
}
else {
echo "_";
$finished = 0;
}
}
echo"</H1>";
if ($finished) {
echo "<BR><BR>Congratulations! You win!<BR><BR>";
echo "<A HREF=$PHP_SELF>Play again</A>";
}
else {
foreach ($alphabet as $var) {
if (ereg($var, $letters)) {
if (ereg($var, $words[$word_number])) {
$links .= "<B>$var</B> ";
} else {
$links .= "$var ";
$wrong++;
}
}
else {
$links .= "<A HREF=\"$PHP_SELF?letters=$letters$var&word_number=$word_number\">$var</A> ";
//echo "$letters$var";
}
}
echo "<BR><IMG SRC=\"./hangman$wrong.gif\"><BR>";
if ($wrong == 12) {
echo "<BR>HANGMAN!!<BR><BR>";
echo "The word you were looking for was \"$word\"<BR><BR>";
echo "<A HREF=$PHP_SELF>Play again</A>";
} else {
echo "Tries remaining = ".(12-$wrong)."<BR>";
echo "<BR>Please pick a letter.<BR><BR>";
echo $links;
}
}
?>
</DIV></BODY>
</HTML>
Qui le righe di errore sono molte, ne riporto solo alcune:
Deprecated: Function ereg() is deprecated in C:\wamp\www\4\ch08\hangman.php on line 20
_
Deprecated: Function ereg() is deprecated in C:\wamp\www\4\ch08\hangman.php on line 20
K
Deprecated: Function ereg() is deprecated in C:\wamp\www\4\ch08\hangman.php on line 35
Deprecated: Function ereg() is deprecated in C:\wamp\www\4\ch08\hangman.php on line 36
Notice: Undefined variable: links in C:\wamp\www\4\ch08\hangman.php on line 37
Deprecated: Function ereg() is deprecated in C:\wamp\www\4\ch08\hangman.php on line 35
A momenti mi arriveranno per posta i manuali di php6 ma siccome questo manuale di php 4 è molto buono ho iniziato tuttavia a studiarlo e sono arrivato a metà e ci terrei a capire come far funzionare gli script...Grazie