Skip navigation.

FLY TO THE ZENITH OF SUCCESS

Arun Raj.R (Software Engineer)

Posts tagged with "php"

What is PHP and its advantages and disadvantages..

,

Hypertext Preprocessor :: PHP some time I used to call Personal Home Page

PHP is an open source server side scripting language that mainly used for developing web applications and web services.

The PHP is very simple for a beginner, but offers many advanced features for a professional script writer.

Three main areas where PHP scripts are used :

1. Server-side scripting
2. Command line scripting
3. Writing desktop applications

Advantages :

1. Open source
2. Simple and very easy to learn.
3. Support for both structural programming and Object Oriented Programming. Use of variable variables $$var.
4. PHP can be used on all major operating systems, including Linux, many Unix variants (including HP-UX, Solaris and OpenBSD), Microsoft Windows, Mac OS X, RISC OS, and probably others. PHP has also support for most of the web servers today. This includes Apache, Microsoft Internet Information Server, Personal Web Server, Netscape and iPlanet servers, Oreilly Website Pro server, Caudium, Xitami, OmniHTTPd, and many others. For the majority of the servers PHP has a module, for the others supporting the CGI standard, PHP can work as a CGI processor.
5. One of the most Sexiest feature of PHP is that it can plugin with most of the databases. It support with Adabas D, dBase, Empress, FilePro (read-only), Hyperwave, IBM DB2, Informix, Ingres, InterBase, rontBase, mSQL, Direct MS-SQL, MySQL, ODBC, Oracle (OCI7 and OCI8), Ovrimos, PostgreSQL, SQLite, Solid Sybase, Velocis and Unix dbm
6. Power ful built in functions. click here to see all php functions
7. PHP also has support services using protocols such as LDAP, IMAP, SNMP, NNTP, POP3, HTTP, COM (on Windows)
8. PHP has extremely useful text processing features, from the POSIX Extended or Perl regular expressions to parsing XML documents. For parsing and accessing XML documents, PHP 5 standardizes all the XML extensions on the solid base of libxml2 and extends the feature set adding SimpleXML and XMLReader support.
9. Easy deployment and cost effective hosting.

Disadvantages :

1. Security flaws due to unknown vulnerabilities .
2. Not good to create desktop Applications

http://www.techaspirant.com/what-is-php-and-its-advantages-and-disadvantages/http://www.techaspirant.com/what-is-php-and-its-advantages-and-disadvantages/

Comparison between various programming languages

, , , ...

Today onwards I am willing to write series of articles about various programming languages. As a programmer we should compare all the programming languages, study its advantage and disadvantages . By these we can consult a correct platform for our clients and we can plug in this in appropriate situation. So advantages and disadvantages over the programming languages again converted for an advantages for the client.

First upon we discuss about programming languages.

A program is list of instructions that perform a particular task or algorithms. A programming language is a machine understandable artificial language that used to write the programs. All programming languages have its own syntax and semantics.

Programming must follow some methodology in programming .

During the year 70s and 80s, the primary software engineering methodology was structured programming. The structured programming approach to program design was based on the following methods:

* To solve a large problem, break down the problem into several pieces and work on each piece separately;
* to solve each piece, treat it as a new problem that can itself be broken down into smaller problems;
* repeat the process with each new piece until each can be solved directly, without further decomposition.

This approach is also called top-down program design.

The Language “C” is considered as a top Structural programming language.

The next was OOP (Object Oriented Programming):

This methodology is organized around “objects” rather than “actions” and data rather than logic. Objects is an identifiable entity with some characteristics and behavior. Object Oriented programming paradigm support the following idioms like information hiding, data abstraction, encapsulation, modularity, polymorphism, and inheritance.

The First OOP languages is “C++”. Then it enhanced by JAVA.

Aspect-oriented programming (AOP) is another programming paradigm that enhance modularity by allowing the separation of cross-cutting concerns, forming a basis for aspect-oriented software development.

These are the main programming paradigms. There is a lot of other paradigms . We will elaborate our knowledge by contributing your suggestions and information about it.

Ready to use Error handling class in your hosted php application

,



Hello Friends,

I have wriiten a class for error reporitng in a php web application. It is a ready made one..

you have to provide your email id.

If you work in localhost it will provide you error in the same page as it occur

but in hosted application the client will only get a custom error message. The same time our error handler class will send a mail to your email id as it occure.. :smile:

Configuration on error.class.php

/**
* Configuration variables.
* @param email
* @param time zone
* $param application name
*/

$email = ‘arunet@gmail.com’;
date_default_timezone_set(”UTC”);
$app_name = ‘Name of the application’;

Download Source code

save this file with extension .php

How to use it ?

Just include this line in each php page

<?php include_once(”error.class.php”) ;?>

Eg.

<?php
include_once(”error.class.php”);
$xmlstr = file_get_contents(’library.xml’);
?>
http://arunrajr.com/blog/wp-content/uploads/2008/12/errorclassDownload Source code

Problem or retrieving rows

,

<?php session_start(); include('session.php'); include('dbquery.php'); $query = QueryExecute("SELECT * FROM draft"); $queryR=mysql_fetch_array($query); foreach ($queryR as $qry) { print_r($qry);echo "
"; } ?> this query displaying only two rows ? whats the problem here ? i think problem is in the foreach stment

How to call url from php using C-url :: alternative to file_get_contents()

, , ,



This is a nice and simple substitute to get_file_contents() using curl, it returns FALSE if $contents is empty.

<?php
function curl_get_file_contents($URL)
{
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_URL, $URL);
$contents = curl_exec($c);
curl_close($c);

if ($contents) return $contents;
else return FALSE;
}
?>

Variable Variables in PHP : Power of PHP

,



Power of PHP extended to use a variable variables.

Example:

Sometimes it is convenient to be able to have variable variable names. That is, a variable name which can be set and used dynamically. A normal variable is set with a statement such as:
<?php
$a = ‘hello’;
?>

A variable variable takes the value of a variable and treats that as the name of a variable. In the above example, hello, can be used as the name of a variable by using two dollar signs. i.e.
<?php
$$a = ‘world’;
?>

At this point two variables have been defined and stored in the PHP symbol tree: $a with contents “hello” and $hello with contents “world”. Therefore, this statement:
<?php
echo “$a ${$a}”;
?>

produces the exact same output as:
<?php
echo “$a $hello”;
?>

i.e. they both produce: hello world.

Symfony - The PHP Frame work :: Based on MVC architecture !!

, , , ...

Symfony is a full-stack framework , a library of cohesive classes written in PHP5 . Symfony provides an architecture, components and tools for developers to build complex web applications faster. Symfony help you to develop your applications @ early, low cost, secure scalable and maintain them easily .

Symfony Features
Symfony was built in order to fulfill the following requirements:

Easy to install and configure on most platforms (and guaranteed to work on standard *nix and Windows platforms)
Database engine-independent
Simple to use, in most cases, but still flexible enough to adapt to complex cases
Based on the premise of convention over configuration–the developer needs to configure only the unconventional
Compliant with most web best practices and design patterns
Enterprise-ready–adaptable to existing information technology (IT) policies and architectures, and stable enough for long-term projects
Very readable code, with phpDocumentor comments, for easy maintenance
Easy to extend, allowing for integration with other vendor libraries
Automated Web Project Features
Most of the common features of web projects are automated within symfony, as follows:

The built-in internationalization layer allows for both data and interface translation, as well as content localization.
The presentation uses templates and layouts that can be built by HTML designers without any knowledge of the framework. Helpers reduce the amount of presentation code to write by encapsulating large portions of code in simple function calls.
Forms support automated validation and repopulation, and this ensures a good quality of data in the database and a better user experience.
Output escaping protects applications from attacks via corrupted data.
The cache management features reduce bandwidth usage and server load.
Authentication and credential features facilitate the creation of restricted sections and user security management.
Routing and smart URLs make the page address part of the interface and search-engine friendly.
Built-in e-mail and API management features allow web applications to go beyond the classic browser interactions.
Lists are more user-friendly thanks to automated pagination, sorting, and filtering.
Factories, plug-ins, and mixins provide a high level of extensibility.
Ajax interactions are easy to implement thanks to one-line helpers that encapsulate cross-browser-compatible JavaScript effects.
Before you get started with symfony, you should understand a few basic concepts. Feel free to skip ahead if you already know the meaning of OOP, ORM, RAD, DRY, KISS, TDD, YAML,Prototype , PROPEL, and PEAR

http://symfony-project.org

How to Display records page by page ? or how to do pagination using php and my sql

, , , ...

How to Display records page by page ? or how to do pagination using php and my sql ?
<?php
include('includes/database.php'); //this is to execute the query, if you want the sourcecode pls click
/**
* @author ["Arun Raj R , Software Engineer ,Ventures Unlimited Solutions"]
* @copyright 2008
*/

if (isset($_REQUEST['page']))
{
$page = $_REQUEST['page'];
if($page=='' || $page<1)
$page=1;
}
else
{
$page=1;
}
$start_from =($page-1) * 10;
$rs_result = QryExecute("SELECT * FROM table_usp ORDER BY id DESC LIMIT $start_from,10");
while ($row = mysql_fetch_assoc($rs_result)) {

echo $row['id'];
echo $row['name'];

}

?>
I think it may helpful to you . If you have any suggestions or questios pls reply here

How to install /configure GD library for PHP 5 on appache / windows xp ?

, , , ...

The default windows distribution of PHP comes with GD. So enabling the GD extension should be as simple as opening your php.ini file and uncommenting the necessary line. So this line:


Code:
;extension=php_gd2.dll
Should look like this (Remove the preceeding semi-colon):


Code:
extension=php_gd2.dll
Generally, your php.ini file will be in the folder in which you installed PHP.

How to create thumbnails ( Logic )

, , , ...

How to create thumbnails
To generate thumbnails we do the following:

Scan a folder for JPG and PNG files (gd does not support GIF anymore, because the packing algorithm in GIF is copyrighted).
Take each of these images, and load it.
Resize the image.
Save the image as a thumbnail.
The resizing idea is the following:

We assume the thumbnail should be 100 pixels, either wide or high.
We load the original image, and check its dimensions.
If the picture is higher than wide, we set the height of the thumb to 100 pixels.
The width of the thumbnail is the original width multiplied with 100 pixels divided by its height.
Thumbnail height = original width * (100 / original height)
This way we preserve the original aspect ratio.
If the original picture is wider than high, we do the same to the height of the thumbnail.
If they are the same, we simply create a 100x100 pixels image.
Back to table of contents
The PHP functions to use
PHP has a whole lot of functions to help us with generating graphics with gd.

For The example with php try this link
http://icant.co.uk/articles/phpthumbnails/
best of luck
December 2009
M T W T F S S
November 2009January 2010
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31