Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
1
Variable Scope
The scope of a variable is the context within which it is defined.
<?php
$a = 1; /* limited variable scope */
function Test()
{
echo $a; The scope is local within functions,
/* reference to local scope variable */
}
and hence the value of $a is
Test(); undefined in the “echo” statement.
?>
<?php <?php
$a = 1; function Test()
$b = 2; global {
function Sum() static
static $a = 0;
{
global $a, $b; refers to its echo $a;
does not lose
$a++;
$b = $a + $b; global } its value.
}
Sum();
version. Test1();
Test1();
echo $b; Test1();
?> ?>
Cookie Workings
setcookie(name,value,expire,path,domain) creates cookies.
<?php
setcookie("uname", $_POST["name"], time()+36000);
?>
<html>
<body>
<p>
NOTE:
Dear <?php echo $_POST["name"] ?>, a cookie was set on this setcookie() must appear
page! The cookie will be active when the client has sent the
cookie back to the server. BEFORE <html> (or
</p>
</body>
any output) as it’s part
</html> of the header
information sent with
the page.
<html>
<body> $_COOKIE
<?php
if ( isset($_COOKIE["uname"]) )
contains all COOKIE data.
echo "Welcome " . $_COOKIE["uname"] . "!<br />";
else isset()
echo "You are not logged in!<br />"; finds out if a cookie is set
?>
</body>
</html>
use the cookie name as a
variable
وظيفة
• قم بإنشاء موقع دليل هاتف باستخدام من تقنيات ما تعلمتها من قبل
• ذو االمكانيات التالية
الدخول باسم مستخدم وكلمة مسر والتحقق من كونه مسجل من قبل الموقع •
تخزين االسم +رقم الهاتف +رقم الجوال +العنوان +االيميل •
4
Function SearchByName($lines,$Name)
{
foreach ($lines as $line){
$liste = explode("|",$line);
5
• Function updateFileByName($lines,$oldName,$NewName)
• {
• $NewLines = array();
• $newline="";
• foreach ($lines as $line){