i having an error came out each time i echo this on my index.php
below is my switch code, as i’m using php dynamic site hence i use switch to change the data each time when different php is call.
[php]<?php
function title_switch()
{
$var = (isset($_GET[‘page’]) && !empty($_GET[‘page’])) ? $_GET[‘page’] : ‘home’;
switch ($var) {
case ‘home’:
$a[‘title’] = " » Home";
$a[‘meta_d’] = “This page is about my site!”;
$a[‘meta_k’] = “something, somethingelse”;
$a[‘slider1’] = “<script type=“text/javascript” src=”./js/jquery.easing.1.3.js">\n";
$a[‘slider2’] = “<script type=“text/javascript” src=”./js/tms-0.3.js">\n";
$a[‘slider3’] = “<script type=“text/javascript” src=”./js/tms_presets.js">\n";
$a[‘main’] = “<script type=“text/javascript” src=”./js/script.js">\n";
$a[‘pageid’] = “page1”;
$a[‘slider’] = “slide”;
break;
case ‘company’:
$a[‘title’] = " » Company";
$a[‘meta_d’] = “This page is about my site!”;
$a[‘meta_k’] = “something, somethingelse”;
$a[‘all’] = “<script type=“text/javascript” src=”./js/all.js">\n";
$a[‘pageid’] = “page2”;
$a[‘slider’] = “banner”;
break;
default:
$a[‘title’] = " » HTTP 404 - Page Not Found";
$a[‘meta_d’] = “”;
$a[‘meta_k’] = “”;
break;
}
return $a;
}
$details = title_switch();
?> [/php]
this is my index.php on line 21
[php]<?php echo $details['all']; ?>[/php]
if go to www.example.com it will show below error
[code] Notice: Undefined index: all in C:\wamp\www\site\index.php on line 21 Call Stack
Time Memory Function Location
1 0.0035 258968 {main}( ) ..\index.php:0[/code]
if i call www.example.com/company it will not show any error…
may I know where did i went wrong? kinda confuse here…
example: if i call www.example.com/company it didnt show error, but if i call www.example.com it show error.
i wanted this code
[php]<?php echo $details['all']; ?>[/php]
to show only if www.example.com/company and it will not show if www.example.com is call.
the code inside:
[php]<?php echo $details['all']; ?>[/php]
is
[php]case ‘company’:
$a[‘title’] = " » Company";
$a[‘all’] = “<script type=“text/javascript” src=”./js/all.js">\n";[/php]
hope this can give a