Viewed   76 times

I'm looking for something like, but completely local. I don't want to commit to installing something as complex as Apache, then PHP on top of that, just to try out code when I'm offline. Is there anything that can run PHP 5.5 on the local machine without installing an entire server underneath it?



There's no need for a server if using PHP 5.5+ - it has a built-in server (

Just use:

$ cd ~/public_html
$ php -S localhost:8000
Sunday, October 16, 2022

Sure you just need to setup a local web server. Check out XAMPP:

That will get you up and running in about 10 minutes.

There is now a way to run php locally without installing a server: https://.com/a/21872484/672229

Saturday, November 5, 2022

Updated :

This doesn't Work because :

$myphpvar = "<script>document.write(localStorage.getItem('myjsvar'));</script>"; 

Now your PHP $myphpvar variable contains :


when you echo then this is like :

echo "<script>document.write(localStorage.getItem('myjsvar'));</script>"

so this will show your Js variable,because it runs on your browser.

but when you do this in SQL : it look something like below :

$sql="INSERT INTO `pending` (`id`, `myfield`) VALUES ('', '<script>document.write(localStorage.getItem('myjsvar'));</script>')";

For Achieving this, you have to pass your localStorage value to URL,and get it on PHP or use AJAX to post!

window.location.href = window.location.href+"?local="+localStorage.getItem('myjsvar'));
Thursday, September 15, 2022

Since PHP does not have static constructors, you cannot automagically do something when a class is loaded. Your best bet is probably to print the message after the class definition (or use __autoload as Josh instructed, but that might require some reworking on your end).

class Foo
    /* stuff */

echo "Class Foo loaded from " . __FILE__ . "n";

EDIT Sorry to say, but PHP provides absolutely no hook to when a class is loaded or first instantiated, even in the dirtiest corners of its weird extensions. You will not be able to get away without either editing the classes' source files (and use my solution) or organize them in a conventional hierarchy to put them in (and use Josh's solution).

There is feature request #48546 that asks for a way to set a callback to when a file will be included but it's not going anywhere. Otherwise, people seem content with __autoload.

At best, you may call get_declared_classes at any time and see what's already been loaded.

Friday, December 2, 2022

Javascript solution (with involving jQuery, though this should be possible to do without it too):

<script type='text/javascript'>
        var files = [
        for ( var n in files ) {
            var img = $('<img/>');
                alert('error:n' + this.src);
                alert('success:n' + this.src);
            img.attr('src', files[n]);
Saturday, September 3, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :