+ Rispondi alla Discussione
Risultati da 1 a 3 di 3

Hybrid View

  1. #1
    bearfrods Guest

    Predefinito How to get a PHP file to be included across files in different directories?

    Currently I have created some php based webpages and uploaded them to my web hosting server.It has a PHP 5.1.6
    installed.With this I am able to include files only that are in the same directory(they work well using require() fn).If not an error message displaying some "no such file" in directory appears in the page.I would like to use them to be included in different direcetories.What should I do?

  2. #2
    Data Registrazione
    Mar 2007

    Predefinito include or require?

    Hello, you can use, both the two instructions, include or require in php, they to the same, but in different way.
    You should use require_once in php, when the included file should be included, by the php parser engine, only one time while a script or program is parsed.
    Use the php include instruction, as in your case, in any others situations (html files maybe).
    You can see many easy examples at php.net php online manual for the include/require that are very well explained:
    by the way if you like to include files that resides in differents directories, you can use, for example code like this (the include using relative path):
    Codice PHP:
    The include() construct will emit a warning if it cannot find a file; this is different behavior from require(), which will emit a fatal error.

  3. #3
    Data Registrazione
    Mar 2007

    Predefinito include/require example

    p.s in the php online manual, this maybe help you (i have simplified the php.net example):
    Codice PHP:
    // file was missing so include default theme

    Or maybe this works better

    p.s if any more helpn needed just let know

Tag per Questa Discussione

Permessi di Scrittura

  • Tu puoi inviare nuove discussioni
  • Tu puoi inviare risposte
  • Tu non puoi inviare allegati
  • Tu non puoi modificare i tuoi messaggi
  • Il codice BB Ŕ opzione attiva
  • Le smilies sono opzione attiva
  • Il codice [IMG] Ŕ opzione attiva
  • [VIDEO] code is opzione attiva
  • Il codice HTML Ŕ opzione NON attiva