Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > blond question

Reply
Thread Tools

blond question

 
 
Edwin van der Vaart
Guest
Posts: n/a
 
      10-16-2004
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?
--
Edwin van der Vaart
http://www.semi-conductor.nl/ Links to Semiconductors site
http://www.evandervaart.nl/ Under construction
 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?L=FCpher_Cypher?=
Guest
Posts: n/a
 
      10-16-2004
Edwin van der Vaart wrote:
> 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
 
Reply With Quote
 
 
 
 
Edwin van der Vaart
Guest
Posts: n/a
 
      10-16-2004
Lüpher Cypher wrote:
> Edwin van der Vaart wrote:
>
>> 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.

> 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:
<?php include("' . $s . '.php"); ?>

> 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.
<!-- naar boven --> <!-- terug naar de top -->

> 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 )
--
Edwin van der Vaart
http://www.semi-conductor.nl/ Links to Semiconductors site
http://www.evandervaart.nl/ Under construction
 
Reply With Quote
 
=?ISO-8859-1?Q?L=FCpher_Cypher?=
Guest
Posts: n/a
 
      10-16-2004

> <?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

>
> 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
 
Reply With Quote
 
Edwin van der Vaart
Guest
Posts: n/a
 
      10-17-2004
Lüpher Cypher wrote:
>
>> <?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

>>
>> 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

I see.
Thanx for the explanation.
--
Edwin van der Vaart
http://www.semi-conductor.nl/ Links to Semiconductors site
http://www.evandervaart.nl/ Under construction
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Blond Antelope =?ISO-8859-1?Q?R=F4g=EAr?= Computer Support 5 09-09-2007 02:15 AM
"blond hair is very hard to photograph" (???) (Was: I believe Primeau has succeeded) I'm not Farrel you retard Digital Photography 0 11-22-2006 03:20 PM
I'm a stupid blond :( Please help me!!! Jenya C++ 32 10-10-2006 08:29 PM
Hot Killer Blond [HQ] monica Digital Photography 2 10-27-2005 02:56 PM
Blond joke =?ISO-8859-1?Q?Brian_H=B9=A9?= Computer Support 5 06-23-2004 07:51 PM



Advertisments