Closed Thread
Results 1 to 6 of 6

Thread: php include is this possible

  1. #1
    nahsorhseda's Avatar
    nahsorhseda is offline x10 Sophmore nahsorhseda is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    mumbai
    Posts
    116

    php include is this possible

    is this possible the below code
    PHP Code:
    <?
    $abc
    ="somepage.php";
    include(
    '$abc');
    ?>
    when i run the above script it says $abc doesnt exist ...
    iam makin such a include coz the value of $abc keeps on changing
    glad to resolve problems in c++ n php

  2. #2
    Penguin129's Avatar
    Penguin129 is offline x10Hosting Member Penguin129 is an unknown quantity at this point
    Join Date
    Aug 2007
    Posts
    68

    Re: php include is this possible

    Well, if you place a variable directly in a string, the text itself is part of the string and not the value of the variable. If you want to put a variable in a string you can do it via many methods such as using the {} things around the variable inside the string, or like so:
    PHP Code:
    $string "text" $variable "more text"
    But for the sake for simplicity, in the code you posted, you can remove the quotes around $abc.

  3. #3
    Xemnas's Avatar
    Xemnas is offline x10 Elder Xemnas is an unknown quantity at this point
    Join Date
    Sep 2007
    Posts
    812

    Re: php include is this possible

    You need to use double quotes (i.e. ") instead of single quotes in your include(), or remove the quotes altogether. Single quotes parse literally (i.e. variables return as their name, not their value), while no quotes and double quotes parse variables as their value.

    So, change your include() to one of the following:
    PHP Code:
    include("$abc");
    include(
    $abc); 

  4. #4
    Momiji's Avatar
    Momiji is offline x10Hosting Member Momiji is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    Springfield, IL
    Posts
    59

    Re: php include is this possible

    when you are including a variable you do not need the " or the ' that should work.


  5. #5
    nahsorhseda's Avatar
    nahsorhseda is offline x10 Sophmore nahsorhseda is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    mumbai
    Posts
    116

    Re: php include is this possible

    thnks guys u made my work a hell lot easier
    coz i was not able to include i had to use a long 12 line function to do it
    glad to resolve problems in c++ n php

  6. #6
    Momiji's Avatar
    Momiji is offline x10Hosting Member Momiji is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    Springfield, IL
    Posts
    59

    Re: php include is this possible

    lol its alright I was just thinking also that you could use

    PHP Code:
    <?
    $abc 
    "somepage.php";
    include 
    $abc;
    ?>


Closed Thread

Similar Threads

  1. Unstand PHP?
    By o0slowpaul0o in forum Tutorials
    Replies: 8
    Last Post: 01-07-2008, 09:16 PM
  2. Sigo con problemas con phpbb2
    By reciecho in forum Soporte
    Replies: 7
    Last Post: 10-20-2007, 06:28 PM
  3. "PHP Startup: Invalid Library" - Interesting error
    By javaguy78 in forum Free Hosting
    Replies: 5
    Last Post: 03-27-2007, 02:33 PM
  4. PHP Include Support
    By Afterburn in forum Free Hosting
    Replies: 5
    Last Post: 07-05-2006, 09:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers