file_get_contents in dwt template

Posted on 2011-05-06
Last Modified: 2012-05-11
I have the following code in my dreamweaver template:

echo file_get_contents("test.txt");

The problem is that when I have pages at different levels of the file system hierarchy, this code doesn't work correctly (it doesn't rewrite itself to have the right path). I have tried to use the full http path but that doesn't work either.

Note that I CANNOT use include instead of the file_get_contents, as this is not allowed by my IT group.
Question by:karimjohnson
    LVL 70

    Accepted Solution

    Hi karimjohnson,

    So the problem is that DW's regex engine knows to look at include() and require() and change those paths as the page is moved around in the file structure but it doesn't respect file_get_contents()

    If a URL doesn't work, then your IT folks have disable fopen() as well.  Instead of an http full path, use a full server path and see if you get the correct results.  It would look something like this:

    LVL 107

    Expert Comment

    by:Ray Paseur
    You might want to look into these PHP functions and read the user-contributed notes.

    Best to all, ~Ray

    Author Closing Comment


    Featured Post

    Easy Project Management (No User Manual Required)

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
    Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now