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!=-.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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!=-.

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.