Jump to content

two noobish questions here with understanding "..." and a question about cases


HoTDaWg

Recommended Posts

what would you say is the best method for stating the current file. what i mean is, take a look at this:

<?php
echo '<a href='.$_SERVER['PHP_SELF'].'/index.php';
?>

instead of typing in the url, or having to type in php self i heard about ... which makes stating the current file a lot easier. Could someone please explain or point me to a tutorial? thanks.

 

also,

 

take a look at this script

<?php
error_reporting(E_ALL);
$underconstruction = rand(0,3099);
$status = rand(0,3099);
$contactus = rand(0,3099);

$mode = $_GET['mode'];
switch ($mode){
	case "$underconstruction":
	echo "Appologies, our website is currently under construction. /n";
	break;
	case "$status":
	echo "currently, this website is approximately 5% percent complete";
	break;
	case "$contactus":
	echo "The contact us form shall be up momentarily. Thank you for your patience."; 
	break;
	default:
	echo "Appologies, our website is currently under construction. /n";
	break;
}	
?>

when not set on error reporting, no errors show up. But when it is set it echos this error:

Notice: Undefined index: mode in /home/slicksil/public_html/index.php on line 7

what is the best method to avoid this error?

 

thanks for any help possible

.-=!X!=-.

mode has to be set, if the url doesn't contain ?mode= in it, this error will come up, as i understand it

 

to fix it, check that mode is set like this..

 

<?php
  if (isset ($_GET['mode'])) {
    $mode = $_GET['mode'];
  } else {
    $mode = 1;    //set some default value that isn't defined in your switch
  }
?>

 

i guess i don't really understand your first question.. what are you looking for?

thank you for your response.

 

for example, during phpbb scripts or ,"pro scripts" lol i find it intriguing how the website address is still fully functional when the use "..."

 

my question is what does the "..." do in php?

 

thanks

 

.-=!X!=-.

without seeing an example, i would have to say that that isn't php related. you would modify your .htaccess file to something like this

 

RewriteEngine on

 

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

 

RewriteRule ^(.*)$ index.php?route=$1 [L,QSA]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.