Jump to content

mnvdk

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Posts posted by mnvdk

  1. I was just wondering (while wandering)...

    I've always used
    if (!isset($variable))
    to determine whether $variable is set or not.

    I could also check this just by using
    if (!$variable)
    but I've always thought this was less "beautiful", or whatever...

    But what is the major difference between the two ways?
    I'm fairly new to PHP, so I'm not that into the technological specifics of every function, so if there is some major problem by just using
    !$variable, I wouldn't know it.
    Sarcasm: It looks like it works, therefore it's good! The IE way!
  2. Well, I have narrowed it down to the cause of the problem.
    Look at this code snippet:
    [code]
    <html>

    <head>

    <style type="text/css">

    #menu
    {
     
    }
    #a_omos
    {
      position: absolute;
      left: 400px;
    }

    </style>

    </head>

    <body>

    <div id="menu">
    <a id="a_omos" href="omos.htm" target="side">Om

    os</a>
    </div>

    </body>

    </html>
    [/code]

    It will output the wanted result. But just by adding a position: absolute; to the #menu style, it will make linebreak whenever there is a whitespace.

    Like this
    [code]
    <html>

    <head>

    <style type="text/css">

    #menu
    {
      position: absolute;
    }
    #a_omos
    {
      position: absolute;
      left: 400px;
    }

    </style>

    </head>

    <body>

    <div id="menu">
    <a id="a_omos" href="omos.htm" target="side">Om

    os</a>
    </div>

    </body>

    </html>
    [/code]

    Why is this so? How can it be?
  3. I was actually not quite sure where to put this, due to the fact that I have no idea what is causing my problem.

    My problem is, as folllows:

    I have a menu looking like this:

    [code]
    echo('<a id="a_omos" href="'.$_SERVER['PHP_SELF'].'?side=omos" target="side">Om os</a>');
    [/code]

    and it's corresponding style:

    [code]
    #a_omos
    {
      position: absolute;
      left: 400px;
    }
    [/code]
    My problem is, that for some reason, it creates a linebreak between 'Om' and 'os', which is quite annnoying, and I really don't know what could cause this... Anyone experienced anything similar?[table][tr][td][/table]
  4. Ah! Stupid me!
    The problem was in the function ses_var(), while I thought I was declaring: $style = $_SESSION['style']; i was actually declaring style = $_SESSION['style']; without the $-sign, because the ses_var function was declared:

    function ses_var($var,$def) {
      if (!isset($_SESSION[$var]))
      {
        $_SESSION[$var] = $def;
      }
      $var = $_SESSION[$var];
      return $var;
    }

    So my problem is now, how do I declare a variable called $style through the ses_var() func. In other words, how do I write:
    $$var = $_SESSION['$var']; <-- when this doesn't work?

    EDIT: I can of course bypass this by using $_SESSION['var'] instead of $var in the rest of my script/page, but is this recommendable?
  5. Hi all...

    I'm fairly new to PHP, and for some time now, I've had a problem deciding how to transfer variables between pages, and finally i settled for using session variables for this... I'm not sure if it's the best way to do it, for the purposes I have, and if you got some better way please advice me. But, anyway, this is how I've tried to do it:

    in globals.php, I have declared this function:
    function ses_var($var,$def) {
      if (!isset($_SESSION[$var]))
      {
        $_SESSION[$var] = $def;
      }
      $var = $_SESSION[$var];
      return $var;
    }

    in variables.php i use it:
    ses_var('style','def');


    and in index.php i have this:
    <style type="text/css" media="screen">
    <?php include("style/".$style.".css") ?>
    </style>


    both globals.php and variables.php are, of course, included first in index.php.

    My problem is that the variable $style is empty, or undeclared, so it keeps looking for style/.css, instead of style/def.css, as it should... What's my problem? How should I do this?

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