I was trying to add a text file through an iframe in order for my lecture to be able to see and mark my php code. The problem is that 000web.com where I hosted my site does not allow txt files for security reasons.

As a work around I tried to place my php code inside a textarea tag and this still does not work. I would highly appreciate it if someone can assist me with this issue. Basically I want to display my php code inside a php page so that it can be viewed by a visitor.

Hello Vusumuzi . If I understood the only thing you like to do is have the PHP code in the content , so here are two alternative easy ways. There is always the option to use a programming languages code highlighter JavaScript browser text editor.

<?php 
    // First option 
    highlight_file("test.php");

    // second option 
    $phpFileContents = file_get_contents("test.php");
    $phpFileContents = htmlentities($phpFileContents);
    $phpFileContents = str_replace("\n", "<br/>", $phpFileContents);
    $phpFileContents = str_replace("\t", "&nbsp;&nbsp;&nbsp;", $phpFileContents);
    echo $phpFileContents;
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.