I'm a beginner programmer and I'm developing this web app, nothing major; the hardest part was writting to text file (not really hard...)

Anyways, my company policy doesn't allow us to install server softwares on computers. So now, I can't run the PHP code I wrote!!

I am wondering if there is anyway I can run PHP without installing or running any sort of server software.. Like I said, I'm using only the file read/write functions and the include() function. Everything else is XHTML

If there is no way the above can be done; what language can I use to read/write files without needing some sort of server?

Thanks, just point me in the right direction, I'll figure out the rest!

Recommended Answers

All 12 Replies

PHP can run also in command line: http://php.net/manual/en/features.commandline.php
But, if you install PHP 5.4.0 you get also a webserver, just run:

php -S localhost:8000

from the directory with the files to test and you can browse them. Said this, with every programming language you can open a socket and serve data. If there is a problem with restrictions, why not setup a firewall in the working station and block the ports?

We had this problem in uni and we used to use a program called Server2Go
Click Here

Yeah, I have a USB web server but I'm not sure if the IT guys can somehow block that... I also don't want to ask them! Because, then they'll know the one way the system is "failing"

Also, are there any security risks if you run a web server off a USB drive?? I'm on the company desktop, which is connected to the internet AND the intranet...

Why dont you just get a free host and use their web page cPanel to upload your file to there, I doubt you won't be to access it unless the company uses a whitelist as opposed to a black list....

Here, use these:

haha, access denied :(

Try and use the USB server to find out if it can be used or not

Yeah I can access that website & use a USB webserver; but the thing is, I'm making this app for people who barely know how to use Excel. So I have to make it as dumb as possible! That's why I am looking for ways to replace code like

    <?php include($datadir."generic_name.txt"); ?>"/>

with something that people can just run as "offline website"

can likely replace reading with javascript, that can read files:


I've only ever used the XMLHTTPrequest object in AJAX myself, it basically reads a file and returns it to javascript in a variable. Not sure how easy it is to get javascript to write to a file, id imagine there'd be big security issues letting javascript write files and open them.


Well if you can access my website, I can give you a directory for your php files if you like, and a web form to upload them...

Member Avatar

You could use javascript. Honestly. Just use an invisible iframe to serve as the go-between for retrieving file content.

<iframe style="display:none;" id="myIframe" src="/pathtofolder/textfile.txt"></iframe>
<a href="#" onclick="getContentFromIframe('myIframe')">Get the content</a>
<div id="display"></div>
<script type="text/javascript">
function getContentFromIframe(iFrameName){
    var myIFrame = document.getElementById(iFrameName);
    var content = myIFrame.contentWindow.document.body.innerHTML;
    document.getElementById('display').innerHTML = content;

You can use another function to change the src attibute value (i.e. change file). Again you don't need a link, you could use a dropdown which loads data (particular file) as you change the value.

For added goodies, you could use the jQuery and jQueryUI and rerlated CSS CDN references (e.g. from Google) to really spark up your site - no server required. Alternatively, download them and use them locally.

I don't know how useful that is?

I got the bare-bones script from here:


However, writing to files is another matter - I'm not sure that this is do-able with js

From what I gather, it can only be done via ActiveX (IE) using fso. But this IMO could be a security issue if the site was open to the wild, ie accessible to others. But there again if somebody got into your computer, they'd do enough damage without trying to mess with your files through a webpage.


Just checked:

    //this can be put into a function
    var fso = new ActiveXObject("Scripting.FileSystemObject");
    FO = fso.OpenTextFile("C:\\diafol.txt", 2, true,0);
    FO.write("See if this works");
<p>Just some random text - could be used to report on file handling progress / reponse</p>

This works for me under Internet Explorer - although you may need to allow ActiveX and scripts to run in the browser. So you could use this as opposed to the iframe nonsense.

commented: Thank you very much! Really helpful! :) +3
Be a part of the DaniWeb community

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