The @ symbol is the error control operator
(aka the "silence" or "shut-up" operator). It makes PHP suppress any
error messages (notice, warning, fatal, etc) generated by the associated
expression. It works just like a unary operator, for example, it has a
precedence and associativity. Below are some examples:
@echo 1 / 0;
// generates "Parse error: syntax error, unexpected T_ECHO" since
// echo is not an expression
echo @(1 / 0);
// suppressed "Warning: Division by zero"
@$i / 0;
// suppressed "Notice: Undefined variable: i"
// displayed "Warning: Division by zero"
@($i / 0);
// suppressed "Notice: Undefined variable: i"
// suppressed "Warning: Division by zero"
$c = @$_POST["a"] + @$_POST["b"];
// suppressed "Notice: Undefined index: a"
// suppressed "Notice: Undefined index: b"
$c = @foobar();
echo "Script was not terminated";
// suppressed "Fatal error: Call to undefined function foobar()"
// however, PHP did not "ignore" the error and terminated the
// script because the error was "fatal"
What exactly happens if you use a custom error handler instead of the standard PHP error handler:
If you have set a custom error handler function with
set_error_handler() then it will still get called, but this custom
error handler can (and should) call error_reporting() which will
return 0 when the call that triggered the error was preceded by an @.
This is illustrated in the following code example:
function bad_error_handler($errno, $errstr, $errfile, $errline, $errcontext) {
echo "[bad_error_handler]: $errstr";
return true;
}
set_error_handler("bad_error_handler");
echo @(1 / 0);
// prints "[bad_error_handler]: Division by zero"
The error handler did not check if @ symbol was in effect. The manual suggests the following:
Applications can contain hundreds and even millions of records. Members
of a site, artist information, a list of images.all these items can be
displayed. If the application contained hundreds of records and
displayed the content to the user all at once, the user would be
overwhelmed with too much data at a single time. The user also might
become frustrated by the time it takes for the content to load because
the query would fetch all the records at once.
You can solve the dilemma by using pagination, which allows applications
to fetch smaller result sets there by displaying content in manageable
and faster loading portions. The result sets are usually broken up into
numbered pages. For example, if you have 1,000 records and applied
pagination, you can display the content in a set 10 pages, each page
containing 100 records. As the user continues to click on the next page,
the application retrieves the next set of data.
To add pagination to any application, you can use the Zend_Paginator
library, which has the capability to paginate any collection of data in
an array as well as result sets from a database using the Zend_Db_Select
object. It also allows you to apply any type of view to render the
content.
Using the Zend_Paginator
The Zend_Paginator can be used by loading the Zend_Paginator class into a PHP file.
After the class is loaded, you can instantiate a Zend_Paginator
object using its constructor and supply it with a Zend_Paginator_Adaptor
object. The supported adaptors are the following:
Zend_Paginator_Adaptor_Array
Zend_Db_Select
Zend_Db_Table_Select
. Iterator
Depending on the type of data you want to paginate, use the required
adaptor. If you want to paginate data for an array, use the
Zend_Paginator_Adaptor_Array class. To use database result sets, you can
create either a Zend_Db_Select object or a Zend_Db_Table_Select object.
You can also allow Zend_Paginator to automatically create the adaptor
for you by using the Zend_ Paginator :: factory() method and pass in an
array or the object you want to use.
The Zend_Paginator provides additional functionality to manipulate
the data presented to the user. These methods are shown in Table.
Aside from providing helpful methods, Zend_Paginator requires
interaction by the user. The user must click a given page number to
inform the Zend_Paginator what set of records it needs to fetch.
Depending on the current page the user is on, a different set of records
will be displayed. To determine which page the user is requesting, you
need to use a query to pass in the data. Retrieving the page number is
then something the PHP file must capture using the Request object.
Using the table, lets work on a small example that will use the
methods and the factory() method. What youll need is an action and a
view. Open the ArtistController.php file and create listAction(). The
action will contain the pagination example shown in Listing.
Listing ArtistController.php: listAction()
/**
* Display all the Artists in the system.
*/
public function listAction(){
//Create a sample array of artist
$artist = array("Underworld", "Groove Armada", "Daft Punk",
"Paul Oakenfold", "MC Chris",
"Ramones",
"The Beatles", "The Mamas and the Papas",
"Jimi Hendrix");
//Initialize the Zend_Paginator
$paginator = Zend_Paginator::factory($artist);
$currentPage = 1;
//Check if the user is not on page 1
$i = $this->_request->getQuery('i');
if(!empty($i)){ //Where i is the current page
$currentPage = $this->_request->getQuery('i');
}
//Set the properties for the pagination
$paginator->setItemCountPerPage(2);
$paginator->setPageRange(3);
$paginator->setCurrentPageNumber($currentPage);
$this->view->paginator = $paginator;
}
Listing demonstrates the new listAction(). The method begins by
initializing the data youll paginate through. Its a set of nine
electronic music artists, all contained in an $artist array. Once
initialized, you create a Zend_Paginator object and use its factory
method to pass in the data to paginate. Because youre using an array,
this will become a Zend _Paginator _Adaptor _Array object behind the
scenes.
You now need to determine what page the user is on. To do this, pass a
query value using the URL. The query value is represented by the
variable i, and the URL will look like this:. If the variable i is not
set, you know that the user is in the initial page, and you can use the
default value you set as 1. Finally, set the total number of artists to
display in a single page, 2; set the number of pages to display in the
paginator control, 3; and set the page the user is currently loading for
this request.
Create a new file in the views/scripts/artist directory and call it
list.phtml. The view will render the records. Copy the code shown in
Listing into the list.phtml file.
Listing list.phtml
<?php echo $this->doctype('XHTML1_STRICT'); ?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<?php echo $this->headTitle('LoudBite.com - Artist Listing'); ?>
</head>
<body>
<?php echo $this->render("includes/header.phtml")?>
<table border='0' width='600'>
<?php
if ($this->paginator)
{
foreach($this->paginator as $item)
{
echo "<tr><td>".$item."</td></tr>";
}
}
else{?>
<tr>
<td>There were no artists present in the system.
Add one now!</td></tr>
<?php
}
?>
</table>
</body>
</html>
Listing builds on the example shown in Listing. Unlike the previous
example, you append the call to render the paginator’s control. You use
the paginationControl() method to do so and pass in three parameters.
The initial parameter is the object you created in the listAction:
$paginator. The second parameter is the scrolling style from Table. The
third parameter is the location of the pagination control view; in the
example, it’s in the includes folder. the resulting pagination
controller and the list of artists, as shown below.
Create 3 directory in your project directory i.e. application, library and public
after that follow the following steps -
1. download the latest library file for zend and paste the library's zend folder in library section.
2. create the following folder in the application folder -
configs, controllers, models, views, forms, layouts
3. create a index.php in the public folder and paste the following code
--------------------------------Start Index.php ------------------------------------------------------------
<?php // Define path to application directory defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
The DNS (Domain Name System)
is a massive network of servers that comprises the largest digital
database on the planet. This database is maintained, managed and
regulated by several internet authorities, including the IANA (Internet
Assigned Numbers Authority) and ICANN (Internet Corporation for Assigned
Names and Numbers).
Many people confuse the various terms
associated with the DNS and mistakenly refer to them as either the same
thing or completely separate entities. In truth, they are neither
separate nor are they the same thing; rather, they are integral pieces
to the puzzle that is the world wide web.
If you're interested
in learning the difference between a DNS and a name server, then you may
want to consider the following information. What is the DNS?
Contrary
to a seemingly popular misconception, DNS does not stand for Domain
Name Server or Domain Name Software. DNS is an abbreviation for the
aforementioned system that catalogs every domain and IP address on the
internet, including registration information, as well as their relation
to other domains and web hosts. The DNS is the central database of the
internet, and without it, the internet would cease to exist as we know
it.
Before the domain name system was devised, computers would
connect to each other via IP addresses, which are strings of segmented
numbers separated by dots. An example of an IP address would be
127.0.0.1 (a common IP address for a local router). The domain name
system attaches a name to this number so that site visitors can easily
remember and return to web addresses. What is DNS Software?
DNS
software is a program that is installed on a web server and used to
facilitate the transference of data related to the domain name system.
Technically, any web server can have DNS software installed on it,
making the server a name server; however, some web hosts will not allow
you to install or configure software within your hosting control panel,
especially in shared hosting plans.
If you’re interested in
installing DNS software on a web server to create a custom nameserver,
you'll either need a VPS or dedicated hosting plan, unless you'd like to
invest several thousand dollars in a private web server. What is a Name Server?
A
name server is a web server that has DNS software installed on it,
particularly a server that is managed by a web host that is specifically
designated for managing the domain names that are associated with all
of the hosting provider's accounts.
Name servers are often
called DSN servers as well, and this is likely the origin of all of the
confusion associated with name servers and the DNS.
Every web
site has two name servers to which it is pointed, and this process must
be done by the webmaster upon purchasing a domain and a hosting account.
If you have more questions about domain name pointing and your web
hosting name servers, it is recommended that you contact your web
hosting provider.
I had designed a perfect form validation using javascript regular
expression. Simple code and works perfect in all conditions. It's very
useful and supporting all the web browsers just take a look at post live demo.
Name:
Alphabets, numbers and space(' ') no special characters min 3 and max 20 characters.
How to use .htaccess file inside the folder. I'm using two
.htaccess files in my hosting, one for labs.9lessons and another for
touch.9lessons. Just take a look at this post how I had implemented.
Original URL : http://www.9lessons.info/touch/index.php?id=srinivas
to
Friendly URL : http://touch.9lessons.info/srinivas
First .htaccess file
This code redirects sub domain http://touch.9lessons.info pointing to touch folder.
This post explains how to create SEO friendly URL with dynamic content
using PHP and .htaccess mod redirection. Friendly URLs improves your
site search engines ranking. Before trying this you have to enable
mod_rewrite.so module at httpd.conf. It’s simple just few lines of PHP
code converting title data to clean URL format.
Database
Sample database blog table columns id, title, body and url.
CREATE TABLE blog
( id INT PRIMARY KEYAUTO_INCREMENT, title TEXT UNIQUE, body TEXT, url TEXT UNIQUE,
);
Publish.php
Contains PHP code. Converting title text to friendly url formate and storing into blog table.