How To Print The PHP Version In A PHP Script

Somebody recently asked me how to print the PHP version from within the PHP script. The answer is very simple and requires only two words to print the PHP version. Here is the script


<?php
echo PHP_VERSION;
?>

PHP_VERSION is a predefined constant. It contains the value of the PHP version.

A sample output is as follows.

[sudheer@localhost cli]$ php php_version.php 
5.2.6
[sudheer@localhost cli]$ 
Taxonomy upgrade extras: 

PHP Script To Shorten URLs Using short.ie

We all know about the URL shortening service offered by many websites. Most notable among them is tinyurl.com. There are also other free URL shortening services available on the Internet.

In this post, I will show you how to generate a short URL link to any URL from a PHP script using the short.ie URL shortening service. The actual code is only about ten lines. We will make use of the Zend_Http_Client component of the Zend Framework.

Taxonomy upgrade extras: 

Include Path

What is include_path?

To include a file in your PHP script you use the include statement. Hard coding the complete file system path in all your include statements is unmaintainable. You cannot expect your application to be installed in the exact same location everywhere. Including the files from a relative path is so much more easier.

Let us write few simple scripts for demonstration purpose.

Create the file mymainfile.php and paste the below code in it.


<?php
/* @file mymainfile.php
 *
 */
echo "This is the main file" "\n";
include 
'subfile.php';
?>
Programming: 
Content Type: 

PHP Essentials

PHP Essentials is a tutorial aimed to help boost your PHP knowledge. The tutorial assumes you have some experience writing PHP scripts.

I have seen many people struggle with Zend Framework because of lack of PHP knowledge. Reading this series before you start using Zend Framework or any other PHP framework will help you immensely.

Programming: 
Content Type: 

How To Access View Object From View Helper

From your view helepr you might want to access

  • view object properties
  • the view object
  • another view helper

You will be able to do all of the above if the view object is available in your view helper. To make sure view object is available to your helper do any of the following

  • Easiest method: Extend Zend_View_Helper_Abstract
    Example:

    class My_View_Helper extends Zend_View_Helper_Abstract{}
  • Implement the Zend_View_Helper_Interface
Programming: 
FOSS Project: 

How To Access The Request Object From Any Part Of Your Application

The request object contains the name of the module, controller, action and the request parameters. Sometimes, you might want to access the request object outside the controller or controller plugin.

For example a user on #zftalk just asked
"how can I access request object within form's method?"

The front controller instance is a singleton. This means we can get the instance of the front controller from any part of our application using the static method getInstance().

FOSS Project: 
Content Type: 
Programming: 

OpenOffice.Org Won't Launch

I encountered this annoying issue today. OpenOffice.Org won't lunch at all. Clicking the OpenOffice.org icon from the GNOME panel application menu and clicking on a ODS file in nautilus had the same results. I could see the window information 'starting openoffice.org' on the bottom GNOME panel. It would soon disappear.

To troubleshoot the issue, I updated the system. There were new OpenOffice.org-* packages available. Updating the packages didn't fix the issue.

Taxonomy upgrade extras: 

Know The Difference Between Zend And Zend Framework

Many people think 'Zend' is the latest trend in PHP. They also think the popular PHP library out there is called Zend.

These notions are absolutely wrong. Before you start working with Zend Framework, get to know the facts.

Zend is a company that has several products - Zend engine, Zend Studio, et all. Zend develops a PHP library with community contributions. This library or framework is known as the Zend Framework.

If you find yourself saying something like , "I tried Zend and I didn't like it, so I use Cake", it is high time you read more about these:

http://www.zend.com/

Content Type: 
Programming: 
FOSS Project: 
General: 

Exporting MySQL Data To CSV In PHP

Do you want to export data stored in a MySQL database to CSV file?

The solution is damn easy if you already know how to connect to MySQL database and read or display data from a PHP script. Let's start working on it.

Let us first create a sample table. In our example scenario, let us create a table to store contact information.


CREATE TABLE `contacts` (
`first_name` VARCHAR( 50 ) NOT NULL ,
`middle_name` VARCHAR( 50 ) NOT NULL ,
`last_name` VARCHAR( 50 ) NOT NULL ,
`email` VARCHAR( 320 ) NOT NULL ,
`phone` VARCHAR( 20 ) NOT NULL
) ENGINE = MYISAM;

Taxonomy upgrade extras: 

CTRL+L Keyboard Shortcut Won't Lock Screen In GNOME

In the recent past, the default keyboard shortcut, CTRL+L set to lock the screen had stopped working. I tried manually setting different keyboard shortcuts like CTRL+ALT+L. None of them would work.

To set the keyboard shortcuts

  • Click System on the GNOME Panel
  • Click Preferences from the drop down menu
  • Click Personal and then click Keyboard Shortcuts
  • Select an action and then type the keyboard shortcut
  • Click Close
Taxonomy upgrade extras: 

Pages