Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Thursday, July 23, 2009

Simple PHP socket-based terminal chat

Some time ago I decided it would be interesting to write an extremely simple PHP terminal chat to try out PHP's sockets and the socket_select() function usage. If you're not in to reading, feel free to skip to the samples and/or the sources ;)

What is a socket_select() (or *_select() for that matter) you ask?

Tuesday, April 28, 2009

Opening a PHP to Java socket

In a project I've been working on recently we needed to integrate a functionality we have in a few Java classes we developed in to a PHP script. If those specific classes could be wrapped in a simple command-line app, it would not have been a problem, as you can execute command-line apps from PHP easily. But! These specific Java classes took very long time to load (around two seconds!) before they could be used.

Saturday, February 7, 2009

Accessing command line from PHP code

It is sometimes necessary (or easier) to execute command line commands from within PHP code, in this post I will show an example of such usage. If you only need an über-basic example, here it is:

<?php

$thisf = $_SERVER['SCRIPT_NAME'];
`cp
$thisf newname.php`;

?>


This little piece of code will copy the running script to newfile.php. If you're not satisfied yet, keep reading.