calling functions with include

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default calling functions with include

    suppose i have...

    <?php
    include("common_functions.php");
    fxn1();
    fxn2();
    ?>

    i want fxn1 and fxn2 to be on the common_functions.php page, but every time
    i do that i get a Fatal Error: Call to undefined function: fxn1() in
    /home/paradox/public_html/index.php
    I'm guessing i would get an error for fxn2 but since it's a fatal error
    the code never gets executed far enough to see if it happens.

    does it make a difference if i put a space after the one aka fxn1 () or
    fxn1() or are they same? I've seen them written differently on different
    sites.

    if i call fxn1() and fxn2() directly from common_functions.php it works
    beautifully, it's only when i try calling it from index.php using the
    include feature

    i've used "include" and "require_once" but i thought by doing it would
    basically cut and paste all the code from common_function.php into the
    index.php so that i could just call the function with no worries.

    paradox Guest

  2. Similar Questions and Discussions

    1. Calling other functions
      All, Using .NET 1.1, I have built a custom control, however I am having trouble compiling it. For the on click event of the button, I want it to...
    2. Calling functions from main.asc
      hi all, i'm new to flash com server ... made the following example to explain what i'm trying to do... the bottom line is that i want to forexample...
    3. Functions in Include File - too large??
      To all, I have an Intranet that I have developed which uses templates and all ASP functions in separate included ASP files. For instance,...
    4. Calling functions?
      Hello, I wrote a jscript function within the HTML window of my webpage and would like to call it from inside the ASPX code-behind page. Any...
    5. calling functions
      how do i call a vbscript function (which is between <%%>) from a vbscript script function (which is between script tags-<script...
  3. #2

    Default Re: calling functions with include

    paradox wrote:
    > suppose i have...
    >
    > <?php
    > include("common_functions.php");
    > fxn1();
    > fxn2();
    >>
    >
    Check if the common_functions.php file resides in the same directory as the
    script that includes it and that this script is called/included from the
    same directory.

    Below is a situation which could cause an error:

    Directory structure:

    ../index.php (file in root dir, accessed by the browser)
    ../files/include.php (includes common_functions.php)
    ../files/common_functions.php

    When index.php includes the include.php file, the include call to
    common_functions.php in include.php should have the same path as index.php
    uses to include include.php:

    index.php:

    <? include "files/include.php" ?>

    include.php:

    <? include "files/common_functions.php" ?>

    Another way to test this is to use require instead of include. The require
    construct throws a fatal error, where include only throws a warning, which
    is probably surpressed in your configuration.


    JW



    Janwillem Borleffs Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139