blond question

  • Thread starter Edwin van der Vaart
  • Start date
E

Edwin van der Vaart

G'day,

I'm trying to create an alternative frame with a php script.
I was trying to convert a php style sheet switch mechanisme into a php
content switch.

Style sheet switch mechanisme:
<?php
$s = $_GET['style'];
if (!($s)) { $s = 'style'; }
?>

<link rel="stylesheet" type="text/css" <?php echo ' href="' . $s .
'.css"'; ?> >

<a href="index.php?style=vert#vertical">Vertical css rollover</a>

Content switch:
<?php
$s = $_GET['php'];
if (!($s)) { $s = 'php'; }
?>

<a href="index.php?php=test.php#opleiding">Mijn opleiding</a>

<?php include("' . $s . '.php"); ?>

I got a "Parse error: parse error in ../../../index.php on line...
What am I doing wrong with the above content switch script?
 
?

=?ISO-8859-1?Q?L=FCpher_Cypher?=

Edwin said:
G'day,

I'm trying to create an alternative frame with a php script.
I was trying to convert a php style sheet switch mechanisme into a php
content switch.

Style sheet switch mechanisme:
<?php
$s = $_GET['style'];
if (!($s)) { $s = 'style'; }
?>

<link rel="stylesheet" type="text/css" <?php echo ' href="' . $s .
'.css"'; ?> >

<a href="index.php?style=vert#vertical">Vertical css rollover</a>

Content switch:
<?php
$s = $_GET['php'];
if (!($s)) { $s = 'php'; }
?>

<a href="index.php?php=test.php#opleiding">Mijn opleiding</a>

<?php include("' . $s . '.php"); ?>

I got a "Parse error: parse error in ../../../index.php on line...
What am I doing wrong with the above content switch script?

That's more like for alt.php :)
Anyways, first of all, get a habit of writing something like this:
if (!isset($s)) ...
A string may evaluate to false.
Then, which line is the error on? By the way, for readability I'd rather
write
<?php include("$s.php"); ?>
or, if you want to make a distinction of the variable,
<?php include("{$s}.php"); ?>
Also, don't get why you'd use those quotes there, if $s = "abc", then
you are trying to include a file named '.abc.'.php
 
E

Edwin van der Vaart

Lüpher Cypher said:
Edwin said:
G'day,

I'm trying to create an alternative frame with a php script.
I was trying to convert a php style sheet switch mechanisme into a php
content switch.

Style sheet switch mechanisme:
<?php
$s = $_GET['style'];
if (!($s)) { $s = 'style'; }
?>

<link rel="stylesheet" type="text/css" <?php echo ' href="' . $s.
'.css"'; ?> >

<a href="index.php?style=vert#vertical">Vertical css rollover</a>

Content switch:
<?php
$s = $_GET['php'];
if (!($s)) { $s = 'php'; }
?>

<a href="index.php?php=test.php#opleiding">Mijn opleiding</a>

<?php include("' . $s . '.php"); ?>

I got a "Parse error: parse error in ../../../index.php on line...
What am I doing wrong with the above content switch script?

That's more like for alt.php :)
It could be. It also could be in alt.html, because the php script is
related to html. :-D
Anyways, first of all, get a habit of writing something like this:
if (!isset($s)) ...
Okay, I'll change it.
A string may evaluate to false.
Then, which line is the error on?
Sorry that was on:
By the way, for readability I'd rather
write
<?php include("$s.php"); ?>
If I use this, then I get some hidden html comments, e.g.
or, if you want to make a distinction of the variable,
<?php include("{$s}.php"); ?>
It's working. Great.
Also, don't get why you'd use those quotes there, if $s = "abc", then
you are trying to include a file named '.abc.'.php
I was including a standard content file. When you click on a link in the
menu, only the content file will change (just like a frame ;-))
 
?

=?ISO-8859-1?Q?L=FCpher_Cypher?=

I was including a standard content file. When you click on a link in the
menu, only the content file will change (just like a frame ;-))

No, I mean, a string in PHP can be enclosed in "" or in ''. Once you
opened the string with ", ' is not considered for closing that string
anymore but as a regular character to be included in the string. So, if
you want to take the variable outside of the string, you'd just write
include($s.".php"), without the single quotes :)
 
E

Edwin van der Vaart

Lüpher Cypher said:
No, I mean, a string in PHP can be enclosed in "" or in ''. Once you
opened the string with ", ' is not considered for closing that string
anymore but as a regular character to be included in the string. So, if
you want to take the variable outside of the string, you'd just write
include($s.".php"), without the single quotes :)
I see.
Thanx for the explanation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top