PHP is really full of functions for everything! Most of the time when you try to do something with strings, there’s a function that can do it better and faster.
The Route from $_GET to String
The global arrays in PHP contain request parameters. Either GET or POST. As you know if the page address is something like:
This means that you pass to the index.php file two parameters – “a” and “key” with their values: “b” and “value”. Now in this case you can dump the $_GET global array somewhere in index.php and you’ll receive something like this.
I’ve seen mostly GET requests, although Zend_Http_Client can perform various requests such as POST as well.
// new HTTP request to some HTTP address$httpClient=new Zend_Http_Client('http://www.example.com/');// GET the response$response=$httpClient->request(Zend_Http_Client::GET);
Here’s a little snippet showing how to POST some data to a server.
// new HTTP request to some HTTP address$client=new Zend_Http_Client('http://www.example.com/');// set some parameters$client->setParameterPost('name','value');// POST request$response=$client->request(Zend_Http_Client::POST);
Note that the request method returns a response. Thus if you are simulating a form submit action you can “redirect” to the desired page just like the form.
// new HTTP request to some HTTP address$client=new Zend_Http_Client('http://www.example.com/');// set some parameters$client->setParameterPost('name','value');// POST request$response=$client->request(Zend_Http_Client::POST);echo$response->location;
You’ve definitely seen the “share a link” screen in Facebook. When you paste a link into the box (fig. 1) and press the “Attach” button you’ll get the prompted cite parsed with a title, description and possibly thumb (fig. 2). This functionality is well known in Facebook, but it appears to be well known also in various social services. In fact Linkedin, Reddit, Dzone‘s bookmarklet use it.
Fist thing to notice is that this information, prompted by Facebook, is the same as the meta tag information. However there is a slight difference.
Facebook prefers for the thumb the image set into the <meta property=”og:image” … />. In the case above this tag appears to be:
Perhaps you think of onfocus and onblur events as a default behavior existing in any web page. This is not quite true! Onfocurs and onblur are well known in web developing (js) and are fired, of course, when the user tries to point something or leaves some element. Onfocurs is fired when the user either goes to an element with the Tab button on with the mouse. When the element is on focus, evidently, the onfocus event is fired. Actually you can see which element is on focus, like an anchor or input, when the element is outlined by the browser by default. In the same scenario, when some element has been on focus and than the user switches to another element, the onblur event is fired. Thus you may guess that this element is no longer on focus. Continue reading Wanted – onfocus/onblur. Why They Don’t Work Always!→
What is typical for most of the web servers is that they listen for requests and respond as quickly as possible on every one of them. In fact the speed of the response is one of the main targets of optimization for developers. Fast servers are what everyone needs. From web developers to website visitors!
In the field of the that battle different web servers have different “weapons” to gain time. While this is useful in most of the cases, when it comes to a chat-like applications and Node.js approaches, the response is not always immediately returned. As I described in my posts until now about Node.js, a simple web server may wait for an event to be emitted, and than return the response. Continue reading Diving into Node.js – A Long Polling Example→