blond question

Discussion in 'HTML' started by Edwin van der Vaart, Oct 16, 2004.

  1. 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
     
    Edwin van der Vaart, Oct 16, 2004
    #1
    1. Advertising

  2. 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
     
    =?ISO-8859-1?Q?L=FCpher_Cypher?=, Oct 16, 2004
    #2
    1. Advertising

  3. 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. :-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:
    <?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
     
    Edwin van der Vaart, Oct 16, 2004
    #3

  4. > <?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 :)
     
    =?ISO-8859-1?Q?L=FCpher_Cypher?=, Oct 17, 2004
    #4
  5. 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
     
    Edwin van der Vaart, Oct 17, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sean
    Replies:
    1
    Views:
    629
    Cowboy \(Gregory A. Beamer\)
    Oct 20, 2003
  2. =?Utf-8?B?UnlhbiBTbWl0aA==?=

    Quick Question - Newby Question

    =?Utf-8?B?UnlhbiBTbWl0aA==?=, Feb 14, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    700
    Iain Norman
    Feb 16, 2005
  3. =?Utf-8?B?YW5kcmV3MDA3?=

    question row filter (more of sql query question)

    =?Utf-8?B?YW5kcmV3MDA3?=, Oct 5, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    977
    Scott Allen
    Oct 6, 2005
  4. Philip Meyer
    Replies:
    0
    Views:
    450
    Philip Meyer
    Nov 30, 2003
  5. Jenya
    Replies:
    32
    Views:
    2,836
    rwannall
    Oct 10, 2006
Loading...

Share This Page