PHP Articles

Latest PHP Auctions

Here a few good deals that you can find today:
Easy Oracle PHP: Create Dynamic Web Pages with Oracle D

US $8.60
End Date: Friday Jul-30-2010 0:40:51 PDT
Buy It Now for only: US $8.60
Buy it now | Add to watch list


Zend Issues Significant Update to Zend Studio 7 Enterprise PHP IDE

Zend Issues Significant Update to Zend Studio 7 Enterprise PHP IDE
Pro Zend Framework Techniques: Build a Full CMS Project

US $12.30
End Date: Friday Jul-30-2010 17:28:09 PDT
Buy It Now for only: US $12.30
Buy it now | Add to watch list

Zend Studio 7.1 Now Supports Task-Focused Programming, Remote Server Synchronization, and PHP Archives.

Read more on PRWeb via Yahoo! News


PHP and MySQL Web Development

Product Description
PHP and MySQL are popular open-source technologies that are ideal for quickly developing database-driven Web applications. PHP is a powerful scripting language designed to enable developers to create highly featured Web applications quickly, and MySQL is a fast, reliable database that integrates well with PHP and is suited for dynamic Internet-based applications.   PHP and MySQL Web Development shows how to use these tools together to produce effective, interactive… More >>

PHP and MySQL Web Development


Twitter Lists – Oh the Possbilities!

I have been using Twitter for a little while now and I think most of you can agree that the more time you put into it, the more you get out of it. Without Twitter I would have never connected with so many like minded people. After using the service for awhile I have started following a large number of many interesting people. Now that Twitter Lists has been added to Twitter, I can finally organize this following into groups.

Twitter made creating a new Twitter list so easy that anyone can take advantage of it. In the right sidebar of your profile, simply click the “New list” link. After this, a dialog box will pop up allowing you to name the list and choose whether your would like it to be public or private. Selecting a private list will only give you access to the list and no one else.

I immediately started four different groups that summarize my current four different interests. The lists that I have created I’ll be adding to and maintaining as time goes on. My four lists are:

  • PHP Tweeters: This list includes a majority of the most influential PHP developers and evangelists.
  • SEO Tweeters: Like the PHP list, the SEO lists includes some very noteworthy SEO specialists.
  • iPhone Tweeters: I have this list just because I have an iPhone and I’m interested in the apps, bug fixes and news.
  • Fun Tweeters: Right now, this list only has in the hosts to the 404 podcast. I’ll be adding other interesting tweeters to this list that don’t really relate to any specific category.

So feel free to follow these lists and if you feel like I am leaving some important Tweeters out of a Twitter List just leave a comment or contact me through the blog. Also please comment your lists that you think would be interesting for other people to follow.


Jabber with PHP – Part I (XMPPHP)

The XMPP-Protocol (which is the official name of the “Jabber”-Protocol) is released under open source, Jabber itself has many advantages in comparison to other instant messaging protocols:

  • It’s open source
  • It’s based on plain-text, xml-style data
  • Everyone can set up a own Jabber-Server
  • It’s decentralized: There are now “central” servers

There are some implementation of this protocol for PHP:

  • XMPPHP (successor to class.jabber.php/CJB)
  • PHP Jabber Client

All these classes are using different approaches – so have a short look. In this article I want to talk about XMPPHP, the PHP Jabber Client will be discussed in the next one.

XMPPHP

Projectpage/Download: Google Code

This class uses CJB as base, it’s easier to use than CJB itself. Similar to CJB it uses the send-wait-read-model; your script will send a message to the connected Jabber-server, wait for a reply and read the reply from the server. This model is easy to use, you can use linear programming, no event-handling is required – but this model can be slow down your script if you will use Jabber extensive.

XMPPHP supports joining chat-rooms and TLS encryption – without much effort. (The sample on the project page is wrong – the parameters are not in a valid order!)

First a simple code example:

<?php
include("xmpp.php");

//username = user without domain, "user" and not "user@server" - home is the resource
$conn = new XMPPHP_XMPP('my.server', 5222, 'username', 'password', 'home');
// Enables TLS - enabled by default, call before connect()!
$conn->useEncryption(true);
$conn->connect();
$conn->processUntil('session_start');
$conn->message('someguy@someserver.net', 'This is a test message!');
$conn->disconnect();
?>

This script will do:

  1. Connect to the talk.google.com-Jabber-Server
  2. Wait until the connection is successful established
  3. Send a message to someguy@someserver.net
  4. Close the connection to the Jabber-Server

Sending a message to a single account is easy – but this call won’t work with a chatroom. For this you have to do this:

...
$conn->connect();
$conn->processUntil('session_start');
// Enter the chatroom
$conn->presence(NULL, "available", "chatroom@server/NickName");
// Send message to chatroom - "groupchat" is required!
$conn->message("chatroom@server", "Test!, "groupchat");
// Leave the chatroom
$conn->presence(NULL, "unavailable", "chatroom@server/NickName");
$conn->disconnect();
...

Finally: How to read messages sent from other users to the used account or within a group-chat? This is event-based, you have to wait for the message-event:

...
$events = $conn->processUntil('message');
foreach($events as $current)
{
  $data = $current[1]; // [0] contains the event type, here "message"
  echo "Message - From: ".$data["from"].", Text: ".$data["body"];
}
...

You can also listen for more than one event (just use an array of strings, so you can wait for “message” and “presence” for example). When joining a chat-room you have to mention you will get also some “older” messages, not only new ones. Additional processUntil() accepts a timeout in seconds as second parameter.

Tobias is a guest writer – visit his blog http://www.mashempires.com, he will launch his start up KnowYourEfforts (a time tracking web application) within few months. Follow Elchie on http://www.twitter.com


  • BrownPHP Tag Cloud

  • Copyright © 1996-2010 Brown PHP. All rights reserved.
    iDream theme by Templates Next | Powered by WordPress

    Powered by Yahoo! Answers