$x=include("x.txt");?

Discussion in 'PHP' started by Adulu, May 1, 2010.

  1. #1
    Hello
    is it possible $x=include("x.txt");?
    echo "$x";(result is x.txt of contents)

    my result always is
    include("x.txt");
    PHP:
    :confused:

    thank you
     
    Adulu, May 1, 2010 IP
  2. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #2
    shallowink, May 1, 2010 IP
  3. Rory M

    Rory M Peon

    Messages:
    1,020
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #3
    
    $x = file_get_contents('x.txt');
    echo $x;
    
    PHP:
    Give that a try
     
    Rory M, May 2, 2010 IP
  4. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #4
    Or you can

    $x="x.txt";
    include($x);
     
    Bohra, May 2, 2010 IP
  5. KrazyBoy

    KrazyBoy Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    i have tested this and its working

    function x($x)
    {include "$x";}

    $x=x("x.txt");
    print $x;
     
    KrazyBoy, May 2, 2010 IP
  6. Adulu

    Adulu Peon

    Messages:
    2,791
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks for everyone.

    this one that is more good for me
    $x = file_get_contents('x.txt');
    echo $x;
     
    Adulu, May 4, 2010 IP