echo From other PHP file

Discussion in 'PHP' started by !Unreal, Apr 28, 2008.

  1. #1
    Ive got a function on one PHP file which is:

    <?php
    $nav = '<div>
      <div align="center">
        <script type="text/javascript" src="stmenu.js"></script>
        </head>
        
        <body>
          <script type="text/javascript">
    ?>
    
    PHP:
    I need to echo this onto another php file. How do I do this?
     
    !Unreal, Apr 28, 2008 IP
  2. PHPGator

    PHPGator Banned

    Messages:
    4,437
    Likes Received:
    133
    Best Answers:
    0
    Trophy Points:
    260
    #2
    I'm assuming you mean variable instead of function?

    The better way to do this I think would be to move variables (as well as functions) that will be used in multiple files and put them in a file called includes.php. Once you do that, if you intend on using them, just do <?php include('includes.php'); ?> and then you should be able to use that variable.
     
    PHPGator, Apr 28, 2008 IP
  3. !Unreal

    !Unreal Well-Known Member

    Messages:
    1,671
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    165
    #3
    So how would I then echo $nav from includes to another file.

    Sorry Im a complete PHP noobie.
     
    !Unreal, Apr 28, 2008 IP
  4. ToddMicheau

    ToddMicheau Active Member

    Messages:
    183
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #4
    
    <?
    include('file.php');
    echo $nav;
    ?>
    
    PHP:
    n_n
     
    ToddMicheau, Apr 28, 2008 IP
  5. !Unreal

    !Unreal Well-Known Member

    Messages:
    1,671
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    165
    #5
    thank you.
     
    !Unreal, Apr 28, 2008 IP