SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry varibles not displaying

    I have a page index.php which im trying to output a variable from a file im including but dosnt show:

    index.php

    <?php
    include "languages/test.php";
    echo "$a";
    ?>

    languages/test.php

    <?php
    $a = "Hello World!";
    ?>

    if i take out the <?php ?> out of languages/test.php it outputs this on page $a = "Hello World! so i know its including the file
    Animated Chatrooms - www.121chatrooms.net

  2. #2
    SitePoint Enthusiast
    Join Date
    Apr 2004
    Location
    Michigan
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try...

    PHP Code:
    <?php
    include("languages/test.php");
    echo 
    "$a";
    ?>

  3. #3
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nope it dosnt seem to trasmit the varibles including from 2 files
    Animated Chatrooms - www.121chatrooms.net

  4. #4
    SitePoint Guru
    Join Date
    Aug 2009
    Posts
    669
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try removing php from the opening tag.

    I've had this problem myself once or twice in the past but I can't remember what on earth solved it (if I ever actually discovered it). All I know is my scripts work ok now.

    Also in your include line change those double quotes for singles unless you've got $variables in there.
    I'll do anything to avoid working on my own code

    Are you using: if (isset($_POST['submit'])) ?
    IE has a bug and does not always send the value.

  5. #5
    Who turned the lights out !! Mandes's Avatar
    Join Date
    May 2005
    Location
    S.W. France
    Posts
    2,496
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    index.php
    PHP Code:
    <?php
    include ('languages/test.php');
    echo 
    $a ' - from index file';
    ?>
    languages/test.php
    PHP Code:
    <?php
    $a 
    "Hello World!";
    echo 
    $a ' - from include file';
    ?>
    See if that works
    A Little Knowledge Is A Very Dangerous Thing.......
    That Makes Me A Lethal Weapon !!!!!!!!

    Contract PHP Programming


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •