Page 187 - Open Soource Technologies 304.indd
P. 187
Open Source Technologies
Notes <body>
<?php
if($_SESSION)
{
$login=$_SESSION[‘login’] ;
}
else
{
$login=””;
}
if($login !=””)
{
include(“member.php”);
}
else
{
include(“notmember.php”);
}
?>
</body>
</html>
Linux stores data and programs in files. These are organized in directories.
11.2 Validating Files
Before you work with a file or directory within your code, it’s often a good idea to learn more
about it, and whether it actually exists is a pretty good start PHE provides many functions to
help you to discover information about files on your system. This section briefly covers some
of the useful functions.
11.2.1 Checking for Existence with file_exists ()
You can test for the existence of a file with the file_exists() function. This function requires a string
representation of an absolute or relative path to a file, which might or might not be present. If
the file if found, the file_exists() function return true; otherwise, it returns false.
if (file_exists (*test.text*)) {
echo “The file exists”;
}
This is all well and good, but what if you’re unsure whether something is a file or a directory,
and you really need to know? Read on!
182 LOVELY PROFESSIONAL UNIVERSITY