PHP Classes

File: Sync.demo.1.php

Recommend this page to a friend!
  Classes of Ninsuo   PHP Sync Files   Sync.demo.1.php   Download  
File: Sync.demo.1.php
Role: Example script
Content type: text/plain
Description: Demo: Hello, world!
Class: PHP Sync Files
Share variables across applications using files
Author: By
Last change: simplified demo reading
Date: 10 years ago
Size: 553 bytes
 

Contents

Class file image Download
<?php

/*
 * This demo demonstrates that the same instance of the Sync class
 * is used, even if two php programs use it.
 *
 * Should be run using PHP Cli
 */

require("Sync.php");

$sync = new Sync("/tmp/demo.sync");

if (isset(
$argv[1]) === false)
{
   
// master process (the one you launched)
   
$sync->hello = "foo, bar!\n";

   
$command = sprintf("/usr/bin/php %s demo", escapeshellarg($argv[0]));
   
exec($command);

    echo
$sync->hello;
}
else
{
   
// child process
   
$sync->hello = "Hello, world!\n";
}