Php global variables
variables are automagically available in all contexts in function and global scopes.
They are named respectively: $ POST, $ GET, $ COOKIE, $ ENV and $ SERVER.
Additionally, a new array called $ REQUEST was added, which contains all $ GET, $ POST and $ COOKIE variables. Variables defined outside of a function are called global variables. They exist in one scope. Variables defined inside of a function are called local variables. The tips to access a global variable inside a function is to use the global keyword. This tells the PHP interpreter that further use of the named variable inside a function should refer to the global variable with the given name, not a local variable. Print the entire $GLOBALS array using PHP's functions for processing associative arrays: <?php reset($GLOBALS); while (list($key, $var) = each($GLOBALS)) { print "$key => $var\ n<br>\ n"; } ?> PHP's list() and each() functions to iteratively process the $GLOBALS array. It then prints the keys names of the variables stored in the $GLOBALS array and their corresponding values. To access a variable that is not declared within the current function, you must do one of two things: either access it through the $GLOBALS array or declare the variable as the global variable. |
Php global variables
PMA06:53
Table Types-MySQL
PMA10:17
MyISAM is the default table type in MySQL Version 3.23. It's based on the ISAM code and
has a lot of useful extensions.
The index is stored in a le with the .MYI (MYIndex) extension, and the data is stored
in a le with the .MYD (MYData) extension. You can check/repair MyISAM tables with the
myisamchk utility.
The following is new in MyISAM:
If mysqld is started with --myisam-recover, MyISAM tables will automaticly be repaired on open if the table wasn't closed properly.
You can INSERT new rows in a table without deleted rows, while other threads are
reading from the table.
Support for big les 63-bit on lesystems/operating systems that support big les.
All data is stored with the low byte rst. This makes the data machine and OS
independent. The only requirement is that the machine uses two's-complement signed
integers (as every machine for the last 20 years has) and IEEE
oating-point format
also totally dominant among mainstream machines. The only area of machines that
may not support binary compatibility are embedded systems because they sometimes
have peculiar processors.
There is no big speed penalty in storing data low byte rst; The bytes in a table row
is normally unaligned and it doesn't take that much more power to read an unaligned
byte in order than in reverse order. The actual fetch-column-value code is also not
time critical compared to other code.
All number keys are stored with high byte rst to give better index compression.
Internal handling of one AUTO_INCREMENT column. MyISAM will automatically update
this on INSERT/UPDATE. The AUTO_INCREMENT value can be reset with myisamchk.
This will make AUTO_INCREMENT columns faster (at least 10 %) and old numbers will
not be reused as with the old ISAM. Note that when an AUTO_INCREMENT is dened on
the end of a multi-part-key the old behavior is still present.
When inserted in sorted order (as when you are using an AUTO_INCREMENT column) the
key tree will be split so that the high node only contains one key. This will improve
the space utilization in the key tree.
BLOB and TEXT columns can be indexed.
NULL values are allowed in indexed columns. This takes 0-1 bytes/key.
Maximum key length is now 500 bytes by default. In cases of keys longer than 250
bytes, a bigger key block size than the default of 1024 bytes is used for this key.
Maximum number of keys/table enlarged to 32 as default. This can be enlarged to 64
without having to recompile myisamchk.
There is a ag in the MyISAM le that indicates whether or not the table was closed
correctly. This will soon be used for automatic repair in the MySQL server.
myisamchk will mark tables as checked if one runs it with --update-state. myisamchk
--fast will only check those tables that don't have this mark.
myisamchk -a stores statistics for key parts (and not only for whole keys as in ISAM).
Dynamic size rows will now be much less fragmented when mixing deletes with updates
and inserts. This is done by automatically combining adjacent deleted blocks and by
extending blocks if the next block is deleted.
myisampack can pack BLOB and VARCHAR columns.
has a lot of useful extensions.
The index is stored in a le with the .MYI (MYIndex) extension, and the data is stored
in a le with the .MYD (MYData) extension. You can check/repair MyISAM tables with the
myisamchk utility.
The following is new in MyISAM:
If mysqld is started with --myisam-recover, MyISAM tables will automaticly be repaired on open if the table wasn't closed properly.
You can INSERT new rows in a table without deleted rows, while other threads are
reading from the table.
Support for big les 63-bit on lesystems/operating systems that support big les.
All data is stored with the low byte rst. This makes the data machine and OS
independent. The only requirement is that the machine uses two's-complement signed
integers (as every machine for the last 20 years has) and IEEE
oating-point format
also totally dominant among mainstream machines. The only area of machines that
may not support binary compatibility are embedded systems because they sometimes
have peculiar processors.
There is no big speed penalty in storing data low byte rst; The bytes in a table row
is normally unaligned and it doesn't take that much more power to read an unaligned
byte in order than in reverse order. The actual fetch-column-value code is also not
time critical compared to other code.
All number keys are stored with high byte rst to give better index compression.
Internal handling of one AUTO_INCREMENT column. MyISAM will automatically update
this on INSERT/UPDATE. The AUTO_INCREMENT value can be reset with myisamchk.
This will make AUTO_INCREMENT columns faster (at least 10 %) and old numbers will
not be reused as with the old ISAM. Note that when an AUTO_INCREMENT is dened on
the end of a multi-part-key the old behavior is still present.
When inserted in sorted order (as when you are using an AUTO_INCREMENT column) the
key tree will be split so that the high node only contains one key. This will improve
the space utilization in the key tree.
BLOB and TEXT columns can be indexed.
NULL values are allowed in indexed columns. This takes 0-1 bytes/key.
Maximum key length is now 500 bytes by default. In cases of keys longer than 250
bytes, a bigger key block size than the default of 1024 bytes is used for this key.
Maximum number of keys/table enlarged to 32 as default. This can be enlarged to 64
without having to recompile myisamchk.
There is a ag in the MyISAM le that indicates whether or not the table was closed
correctly. This will soon be used for automatic repair in the MySQL server.
myisamchk will mark tables as checked if one runs it with --update-state. myisamchk
--fast will only check those tables that don't have this mark.
myisamchk -a stores statistics for key parts (and not only for whole keys as in ISAM).
Dynamic size rows will now be much less fragmented when mixing deletes with updates
and inserts. This is done by automatically combining adjacent deleted blocks and by
extending blocks if the next block is deleted.
myisampack can pack BLOB and VARCHAR columns.
Running MySQL on Windows
PMA10:13
MySQL supports TCP/IP on all Windows platforms and named pipes on NT. The default
is to use named pipes for local connections on NT and TCP/IP for all other cases if the
client has TCP/IP installed. The host name species which protocol is used:
Host name Protocol
NULL (none) On NT, try named pipes rst; if that doesn't work, use
TCP/IP. On Win95/Win98, TCP/IP is used.
. Named pipes
localhost TCP/IP to current host
hostname TCP/IP
You can force a MySQL client to use named pipes by specifying the --pipe option or by
specifying . as the host name. Use the --socket option to specify the name of the pipe.
You can test whether or not MySQL is working by executing the following commands:
C:\mysql\bin\mysqlshow
C:\mysql\bin\mysqlshow -u root mysql
C:\mysql\bin\mysqladmin version status proc
C:\mysql\bin\mysql test
If mysqld is slow to answer to connections on Win95/Win98, there is probably a problem with your DNS. In this case, start mysqld with --skip-name-resolve and use only
localhost and IP numbers in the MySQL grant tables. You can also avoid DNS when
connecting to a mysqld-nt MySQL server running on NT by using the --pipe argument
to specify use of named pipes. This works for most MySQL clients.
There are two versions of the MySQL command-line tool:
mysql Compiled on native Windows, which oers very limited text editing capabilities.
mysqlc Compiled with the Cygnus GNU compiler and libraries, which
oers readline editing.
If you want to use mysqlc.exe, you must copy `C:\mysql\lib\cygwinb19.dll' to
`\windows\system' (or similar place).
The default privileges on Windows give all local users full privileges to all databases. To
make MySQL more secure, you should set a password for all users and remove the row in
the mysql.user table that has Host='localhost' and User=''.
You should also add a password for the root user. (The following example starts by
removing the anonymous user, that allows anyone to access the 'test' database.):
C:\mysql\bin\mysql mysql
mysql> DELETE FROM user WHERE Host='localhost' AND User='';
mysql> QUIT
C:\mysql\bin\mysqladmin reload
C:\mysql\bin\mysqladmin -u root password your_password
is to use named pipes for local connections on NT and TCP/IP for all other cases if the
client has TCP/IP installed. The host name species which protocol is used:
Host name Protocol
NULL (none) On NT, try named pipes rst; if that doesn't work, use
TCP/IP. On Win95/Win98, TCP/IP is used.
. Named pipes
localhost TCP/IP to current host
hostname TCP/IP
You can force a MySQL client to use named pipes by specifying the --pipe option or by
specifying . as the host name. Use the --socket option to specify the name of the pipe.
You can test whether or not MySQL is working by executing the following commands:
C:\mysql\bin\mysqlshow
C:\mysql\bin\mysqlshow -u root mysql
C:\mysql\bin\mysqladmin version status proc
C:\mysql\bin\mysql test
If mysqld is slow to answer to connections on Win95/Win98, there is probably a problem with your DNS. In this case, start mysqld with --skip-name-resolve and use only
localhost and IP numbers in the MySQL grant tables. You can also avoid DNS when
connecting to a mysqld-nt MySQL server running on NT by using the --pipe argument
to specify use of named pipes. This works for most MySQL clients.
There are two versions of the MySQL command-line tool:
mysql Compiled on native Windows, which oers very limited text editing capabilities.
mysqlc Compiled with the Cygnus GNU compiler and libraries, which
oers readline editing.
If you want to use mysqlc.exe, you must copy `C:\mysql\lib\cygwinb19.dll' to
`\windows\system' (or similar place).
The default privileges on Windows give all local users full privileges to all databases. To
make MySQL more secure, you should set a password for all users and remove the row in
the mysql.user table that has Host='localhost' and User=''.
You should also add a password for the root user. (The following example starts by
removing the anonymous user, that allows anyone to access the 'test' database.):
C:\mysql\bin\mysql mysql
mysql> DELETE FROM user WHERE Host='localhost' AND User='';
mysql> QUIT
C:\mysql\bin\mysqladmin reload
C:\mysql\bin\mysqladmin -u root password your_password
Javascript cookie string
PMA10:36
We can set a cookie by setting document.cookie to a cookie string.
The following code will set a cookie with the UserName set as Paul,
and an expiration date of 28 December 2010.
<html>
<head>
<script language=JavaScript>
document.cookie = "UserName=Paul;expires=Tue, 28 Dec 2010 00:00:00;";
</script>
</head>
<body>
<p>This page just created a cookie</p>
</body>
</html>
Save the page as FreshBakedCookie.htm. We'll see how the code works as we
discuss the parts of a cookie string, but first let's see what happens
when a cookie is created.
The following code will set a cookie with the UserName set as Paul,
and an expiration date of 28 December 2010.
<html>
<head>
<script language=JavaScript>
document.cookie = "UserName=Paul;expires=Tue, 28 Dec 2010 00:00:00;";
</script>
</head>
<body>
<p>This page just created a cookie</p>
</body>
</html>
Save the page as FreshBakedCookie.htm. We'll see how the code works as we
discuss the parts of a cookie string, but first let's see what happens
when a cookie is created.
In this section we'll see how to look at the cookies that
are already stored by IE on our computer. We'll then load the cookie-creating
page we just created with the preceding code to see what effect this has.
First we need to open IE. I'm using IE 6, so if you're using IE 4
or 5 you will find the screenshots and menus in slightly different places.
Before we view the cookies, we'll first clear the temporary
Internet file folder for the browser because this will make it easier to view
the cookies that our browser has stored. In IE, select Internet Options from the
Tools menu,
javascript Date, Time
PMA10:30
Javascript Date
The methods getDate(), getDay(), getMonth(), and getFullYear() allow us to
retrieve date values from inside a Date object.
The setDate(), setMonth(), and setFullYear() methods allow us to set the
date values of an existing Date object.
The getHours(), getMinutes(), getSeconds(), and getMilliseconds() methods retrieve the time values in a Date object. The setHours(), setMinutes(), setSeconds(), and setMilliseconds() methods allow us to set time values of an existing Date object. One thing that we didn't cover in that chapter was the idea that the time depends on your location around the world. For example, imagine you have a chat room on your website and want to organize a chat for a certain date and time. Simply stating 15:30 is not good enough if your website attracts international visitors. The time 15:30 could be Eastern Standard Time, Pacific Standard Time, the time in the United Kingdom, or even the time in Kuala Lumpur. You could of course say 15:30 EST and let your visitors work out what that means, but even that isn't foolproof. There is an EST in Australia as well as in the U.S. var localTime = new Date();
This creates a new Date object and
initializes it to the current date and time based on the client computer's
clock. (Note that in fact the Date object simply stores
the number of milliseconds between the date and time on your computer's clock
and midnight UTC time on the 1st of January 1970.)
Within the body of the page we have seven more script blocks that
use the three world time methods we looked at earlier. Note that some of them
are enclosed in an if statement, for example
if (localTime.toLocaleTimeString) { document.write(localTime.toLocaleTimeString()) }
This checks to see if the browser supports that method and only
makes use of it if it does. Older browsers don't support all of the date/time
methods so doing this prevents ugly errors.
In the following line
document.write(localTime.toUTCString());
we write the string returned by the toUTCString() method to the page. This converts the date and
time stored inside the localTime Date object to the equivalent UTC date and time.
|
What is TCP/IP
PMA10:25
What is TCP/IP
The Transmission Control Protocol and the Internet Protocol manage the sending and receiving
of messages as packets over the Internet. The two protocols together provide a service to
applications that use the Internet: communication through a network.
The World Wide Web is a network application that uses the services of TCP and IP to communicate over the Internet. When a web browser requests a page from a web server, the TCP/IP services provide a virtual connection -- a virtual circuit—between the two communicating systems. Remember that packet-switched networks don't operate like telephone networks that create an actual circuit dedicated to a particular call. Once a connection is established and acknowledged, the two systems can communicate by sending messages. These messages can be large, such as the binary representation of an image, and TCP may fragment the data into a series of IP datagrams. An IP datagram is equivalent to the couriers' envelope in that it holds the fragment of the message along with the destination address and several other fields that manage its transmission through the network. Each node in the network runs IP software, and IP moves the datagrams through the network, one node at a time. When an IP node receives a datagram, it inspects the address and other header fields, looks up a table of routing information, and sends it on to the next node. Often these nodes are dedicated routers—systems that form interconnections between networks—but the nodes can also include the computer systems on which the applications are running. IP datagrams are totally independent of each other as far as IP is concerned: the IP software just moves them from node to node through a network. The size of a datagram is primarily determined by the largest size message that can be sent by any part of the network. TCP software performs the function of gluing the fragments together at the destination using the fragment identifier field in the IP datagram header. Because IP datagrams are transmitted through the network independently, there is no guarantee they will arrive at the destination in order, and TCP stores the fragments in a buffer until all preceding fragments are received. IP doesn't guarantee that datagrams are delivered. If an IP node receives a corrupt datagram, it throws it away. Datagrams may be missing from the stream the TCP software receives because a datagram was corrupt and not passed on from the IP software or was delayed in the network. TCP buffers the fragments to allow the out-of-order datagrams to arrive. If a missing datagram fails to arrive, TCP eventually requests that it be resent. This can cause datagrams to be received twice; however TCP recognizes and discards the duplicate datagram when it arrives. |
How to traffic to your website
PMA11:19
How to traffic to your website
1. Article marketing. If you'd like to acquire numerous inbound
links, establish your expertise on your field, and generate enormous
traffic to your site all at the same time, you should definitely
engage to article marketing. It is the most efficient and
cost-effective way to build traffic to your site. All you have to
do is write quality articles that are highly relevant to your
website or products that you promoting and submit these articles
to submission sites.
2. Multiple Pages - If possible, divide the websiteinto several pages and access them through separate items links on a menu or navigation bar. 3. Be consistent - Have same menu or some extensionof it on all pages so that viewers know where they are at all times. Home page is a must on every page. Visitors should be able to easily look around your website. If visitors are frustrated andcan't find what they are looking for, they are likely to leave quickly and never come back or recommend yourwebsite to others.The menu can be located at the top, left or right side of the page. 4. Keep Content Fresh - Static content is dead content; Write new articles, update old ones. New or updated content is a great way to keep visitors coming back. Search engines also rank websites with fresh content higher. Keeping an active blog is a great way to keep your website new and fresh. 5. Use Descriptive File Names - Use descriptive keywords as names for the files like pictures, videos on your site. This will help your site appear more with search engines - especially through Google Image Search. 6. Create Links - Getting links to your website from other websites will help generate more traffic and improve your placement in search engines. Find other websites on your same topic and put a link to them on your site -- maybe in a new Favorite Links page. Then ask those websites to link back to you by signing their guestbook. 7. Tag your Site - Adding tags can increase the number of times your website shows up in search results. To pick the right keywords, try putting yourself in the shoes of your visitors and think whatthey would search for if they wanted to find your site. 8.Visitors Contact You - Make it simple for visitors to reach you if they want. Include a guestbook or blog where they can post questions. Add a contact us form where they can submit questions to you via email. |
Php file uploading code
PMA07:58
Php file uploading code
To uploading a file, two changes must be
made to the standard HTML form. First, the initial FORM line must
include the code ENCTYPE = "multipart/form-data", which lets the
HTML know to expect a file as well other data.
Second, <input name="NAME" type="FILE" /> the element is used to create the necessary field.
Another trap is the size of uploaded files.
Although you can tell the browser the maximum size of file to upload, this is only a recommendation and it cannot ensure that your script won't be handed a file of a larger size. The danger is that an attacker will try a denial of service attack by sending you several large files in one request and filling up the filesystem in which PHP stores the decoded files. The php file uploading code: <form action="" method="post"> Select Filename: <input type="file" name="adFile"> <input type="submit" value="Upload"> </form> <?php move_uploaded_file ($_FILES['adFile'] ['tmp_name'], "../uploads/{$_FILES['adFile'] ['name']}") ?>
Set the post_max_size configuration option in php.ini to the
maximum size in bytes that you want:
post_max_size = 1024768 ; one megabyte The default 10 MB is probably larger than most sites require. |
Php Code for a Valid Number
PMA07:12
Php Code for a Valid Number
Besides working on numbers, is_numeric( ) can also be applied to numeric strings.
Use is_numeric( ):
if (is_numeric('five')) { /* false */ } if (is_numeric(5)) { /* true */ } if (is_numeric('5')) { /* true */ } if (is_numeric(-5)) { /* true */ } if (is_numeric('-5')) { /* true */ }
It is often useful to determine where in the code output originates.
Helpfully, is_numeric( ) properly parses decimal numbers, however, numbers with thousands separators, such as 5,100, cause is_numeric( ) to return false.
To strip the thousands separators from your number before calling
is_numeric( ) use str_replace( ):
is_numeric(str_replace($number, ',', ''));
To check if your number is a specific type, there are a
variety of self-explanatorily named related functions:
is_bool( ) , is_float( ) (or is_double( ) or is_real( );
they're all the same), and is_int( ) (or is_integer( )
or is_long( )).
|
Magic Methods-Php
PMA11:11
Magic Methods and Constants
Magicmethods are specially named methods that
can be defi nedin any class and are executed via builtin PHP functionality. Magic methods always begin with a double underscore. In fact, the magic methods __destruct() and __construct() have already been used several times.
It is often useful to determine where in the code output originates.
This is the purpose of all of the magic constants and is particularlyuseful when writing custom logging functions. The seven magic constants are as follows:
__CLASS__ equates to the class in which the constant is referenced.
As noted earlier, this variable is always equal to the class in which it is defi ned, which is not always the class that was instantiated. For example, __CLASS__ as defi ned inside Node always returns Node even if the method is part of an object that was instantiated as a descendant class. In addition to debugging, the class constant is also useful for static callback functions.
__FILE__ is always equal to the file name where the constant is referenced.
__LINE__ is used in conjunction with __FILE__ in order to output a location in code.
|
Php HTTP Basics
PMA11:15
| Php Web Application Php Email Codes Php Array Php Ifelse Php variables Php Substrings Php Mysql Functions php-sessions |
Php HTTP BasicsWhen a web browser requests a web page, it sends an HTTP requestmessage to a web server. The request message always includes some header information, and it sometimes also includes a body. The web server responds with a reply message, which always includes header information and usually contains a body. The first line of an HTTP request looks like this: GET /index.html HTTP/1.1 This line specifies an HTTP command, called a method , followed by the address of a document and the version of the HTTP protocol being used. In this case, the request is using the GET method to ask for the index.html document using HTTP 1.1. After this initial line, the request can contain optional header information that gives the server additional data about the request. For example: User-Agent: Mozilla/5.0 Windows 2000; U Opera 6.0 [en] Accept: image/gif, image/jpeg, text/*, */* The User-Agent header provides information about the web browser, while the Accept headerspecifies the MIME types that the browser accepts. After any headers, the request contains a blank line, to indicate the end of the header section. The request can also contain additional data, if that is appropriate for the method being used . If the request doesn't contain any data, it ends with a blank line. The web server receives the request, processes it, and sends a response. The first line of an HTTP response looks like this: HTTP/1.1 200 OK This line specifies the protocol version, a status code, and a description of that code. In this case, the status code is "200", meaning that the request was successful hence the description OK. After the status line, the response contains headers that give the client additional information about the response. For example: Date: Sat, 26 Jan 2002 20:25:12 GMT Server: Apache 1.3.22 Unix mod_perl/1.26 PHP/4.1.0 Content-Type: text/html Content-Length: 141 The Server header provides information about the web server software, while the Content-Type header specifies the MIME type of the data included in the response. After the headers, the response contains a blank line, followed by the requested data, if the request was successful. |
socket tcp server with php
PMA10:48
| Php Web Application Php Email Codes Php Array Php Ifelse Php variables Php Substrings Php Mysql Functions php-sessions |
HTTP is the standard that allows documents to be communicated and shared over the Web. From a network perspective, HTTP is an application-layer protocol that is built on top of TCP/IP. Using our courier analogy from the previous section, HTTP is a kind of cover letter—like a fax cover sheet—that is stored in the envelope and tells the receiver what language the document is in, instructions on how to read the letter, and how to reply. Since the original version, HTTP/0.9, there have only been two revisions of the HTTP standard. HTTP/1.0 was released as RFC-1945[A] in May 1996 and HTTP/1.1 as RFC-2616 in June 1999. HTTP is simple: a client—most conspicuously a web browser—sends a request for some resource to a HTTP server, and the server sends back a response. The HTTP response carries the resource—the HTML document or image or whatever—as its payload back to the client. A simulated HTTP request using telnet % telnet www.w3.org 80 Trying 18.29.1.35... Connected to www.w3.org. Escape character is '^]'. HEAD / HTTP/1.1 HTTP/1.1 200 OK Date: Wed, 26 Sep 2001 03:42:32 GMT Server: Apache/1.3.6 (Unix) PHP/3.0.11 P3P: policyref="http://www.w3.org/2001/05/P3P/p3p.xml" Cache-Control: max-age=600 Expires: Wed, 26 Sep 2001 03:52:32 GMT Last-Modified: Tue, 25 Sep 2001 21:08:00 GMT ETag: "5b42a7-4b06-3bb0f230" Accept-Ranges: bytes Content-Length: 19206 Connection: close Content-Type: text/html; charset=us-ascii Connection closed by foreign host. % |
Php session Info and cookies
PMA06:27
Php Web Application
Php Email Codes
Php Array
Php Ifelse
Php variables
Php Substrings
Php Mysql Functions
php-sessions
Php Email Codes
Php Array
Php Ifelse
Php variables
Php Substrings
Php Mysql Functions
php-sessions
Php session Info and cookies
1Cookiesare small files saved on the user’s computer2 Cookies can only be readfrom the issuing domain
3 Cookies can have an expiry time, if it is not set, then the cookie expireswhen the browseris closed
4 Sessions are like global variablesstored on the server
5 Each session is given a unique identification idthat is used to track the variables for a user.
6 Both cookies and sessionsmust be started before any HTML tagshave been sentto the browser.
Cookies are great little tools, but they get a bad rap in the press when nasty people misuse them.
These little bits of text will make your development life much easier if you use them properly.
#Set a cookie
#Extract data from a cookie
Sessions are like cookies on steroids.
Using sessions, you can maintain user-specific information without setting multiple cookies or even using a database.
Start a session
Add a variable to the $_SESSION superglobal
Enable a per-user access count
Maintain user preferences throughout multiple pages
Creating a Simple Php Functions
PMA06:00
Php Web Application
Php Email Codes
Php Array
Php Ifelse
Php variables
Php Substrings
Php Mysql Functions
php-sessions
Php Email Codes
Php Array
Php Ifelse
Php variables
Php Substrings
Php Mysql Functions
php-sessions
Creating a Simple Php Functions
As you program, you'll discover that there are certain sections of code you frequently use, either within a single script or in several. Placing these routines into a self-defined function can save you time and make your programming easier, especially as your Web sites become larger. Once you create a function, the actions of that function take place each time the function is called, just as print() will send text to the browser with each use. The syntax to create a user-defined function is: function FunctionName () { statement(s); }You can use roughly the same naming conventions for the function name as you do for variables, just without the initial dollar sign. The most important rule is to remain consistent. Second to that is the suggestion of creating meaningful function names, just as you ought to write representative variable names CreateHeader would be a better function name than Function1.
Remember not to use spaces, though, as that would constitute two separate words for the function name, which will result in error messages the underscore is a logical replacement for the space, for example Create_Header is a valid function name.
Any valid PHP code can go within the statements area of the function, including calls to other functions. There is also no limit to the number of statements a function has, but make sure each statement ends with a semi-colon.
Internet/E-commerce jobs
PMA10:20
It jobs and computing careers on totaljobs.com find permanent and part time internet
jobs and upload your cv to apply now. Guide to finding jobs online: online job search
tutorial - job the guide to finding jobs online: where and how to find jobs, from
employer websites to social media for job search and job aggregators like indeed.com.
Online jobs search results. Online jobs, part time work from home & data entry jobs
online jobs for students.com is the best place for students to find online jobs and
make money online opportunities tailored to students interviews with students.
Job-hunt.org - jobs, employers, and job search resources and jobhuntorg, free
award-winning jobs portal, one of the web s oldest and most trusted sources of
job search resources and advice.
Best jobs online is your online employment community browse latest job vacancies and
join the recruitment. What are the different types of online jobs internet business
jobs and careers: search jobs in internet business all internet business jobs updated daily.
Simply the best online jobs - ezinearticles submission compare the best job listing solutions
if you post job openings on multiple job boards then these solutions are a must for you
post job openings to multiple job. Online jobs in the philippines there are many types
of online jobs, including working as a graphic artist, a website designer,
a forum moderator, an online.
Part time jobs online, work from home, ad posting jobs, data are you convinced about
the usefulness of the internet for employers recruiting for and filling jobs you should
be you can post jobs online and get the attention of. Part time jobs online, work from
home, ad posting jobs, data learn how to make money online at home discover how teens
make money online with free resources blogging, seo, ad sense and more. Online jobs work
at home part time jobs this blog is made for your benefit and convenience to find online
jobs without any investments and how to work at home without paying fee. Online jobs ph
jobs & careers in online marketing, internet marketing, digital marketing and online
advertising.
Online marketing jobs & careers - internet marketing jobs want to know about an online
job application they are becoming the norm for employers who wants to store hundreds of
paper resumes when you can ask applicants to. Homeworkers - work from home jobs, home
based business search results. Dice.com - official site data entry jobs, offline data
entry jobs, online data entry jobs without registration fees earn $1000 per month work
from home no registration fees data entry jobs. Free online jobs disclaimer all jobs
online posted here are free and not paid advertisements philippine jobs online is not
connected in any way whatsoever to these online job posts. Internet job your work at
home telecommuting resource center find legitimate work at home jobs, information on
how to start a home based business, home based medical courses
jobs and upload your cv to apply now. Guide to finding jobs online: online job search
tutorial - job the guide to finding jobs online: where and how to find jobs, from
employer websites to social media for job search and job aggregators like indeed.com.
Online jobs search results. Online jobs, part time work from home & data entry jobs
online jobs for students.com is the best place for students to find online jobs and
make money online opportunities tailored to students interviews with students.
Job-hunt.org - jobs, employers, and job search resources and jobhuntorg, free
award-winning jobs portal, one of the web s oldest and most trusted sources of
job search resources and advice.
Best jobs online is your online employment community browse latest job vacancies and
join the recruitment. What are the different types of online jobs internet business
jobs and careers: search jobs in internet business all internet business jobs updated daily.
Simply the best online jobs - ezinearticles submission compare the best job listing solutions
if you post job openings on multiple job boards then these solutions are a must for you
post job openings to multiple job. Online jobs in the philippines there are many types
of online jobs, including working as a graphic artist, a website designer,
a forum moderator, an online.
Part time jobs online, work from home, ad posting jobs, data are you convinced about
the usefulness of the internet for employers recruiting for and filling jobs you should
be you can post jobs online and get the attention of. Part time jobs online, work from
home, ad posting jobs, data learn how to make money online at home discover how teens
make money online with free resources blogging, seo, ad sense and more. Online jobs work
at home part time jobs this blog is made for your benefit and convenience to find online
jobs without any investments and how to work at home without paying fee. Online jobs ph
jobs & careers in online marketing, internet marketing, digital marketing and online
advertising.
Online marketing jobs & careers - internet marketing jobs want to know about an online
job application they are becoming the norm for employers who wants to store hundreds of
paper resumes when you can ask applicants to. Homeworkers - work from home jobs, home
based business search results. Dice.com - official site data entry jobs, offline data
entry jobs, online data entry jobs without registration fees earn $1000 per month work
from home no registration fees data entry jobs. Free online jobs disclaimer all jobs
online posted here are free and not paid advertisements philippine jobs online is not
connected in any way whatsoever to these online job posts. Internet job your work at
home telecommuting resource center find legitimate work at home jobs, information on
how to start a home based business, home based medical courses
Adding CSS style in php script
PMA10:07
<?php
echo '<span style="font-size:10px">'; // add styles as style attribute
echo 'test';
echo '</span> ';
echo '<p style="font-size:20px">';
echo $title = $_POST['text'];
echo "</p>";
?>
In PHP, all variable names begin with a dollar sign ($). The $ is followed by an
alphabetic character or an underscore, and optionally followed by a sequence of
alphanumeric characters and underscores. There is no limit on the length of a
variable name. Variable names in PHP are case-sensitive. Here are some examples:
$k
$cot
$Sar_name
$_MPS
In PHP, unlike in many other languages, you do not have to explicitly declare variables.
PHP automatically declares a variable the first time a value is assigned to it.
PHP variables are untyped; you can assign a value of any type to a variable.
PHP uses a symbol table to store the list of variable names and their values.
There are two kinds of symbol tables in PHP: the global symbol table, which stores
the list of global variables, and the function-local symbol table, which stores the
set of variables available inside each function.
Dynamic Variables
Sometimes it is useful to set and use variables dynamically. Normally, you assign a variable like this:
$var = "derro";
Now let's say you want a variable whose name is the value of the $var variable. You can do that like this:
$$var = "Jinna";
PHP parses $$var by first dereferencing the innermost variable, meaning that
$var becomes "derro". The expression that's left is $"hello", which is just $derro.
In other words, we have just created a new variable named hello and assigned it
the value "Jinna". You can nest dynamic variables to an infinite level in PHP,
although once you get beyond two levels, it can be very confusing for someone who
is trying to read your code.
echo '<span style="font-size:10px">'; // add styles as style attribute
echo 'test';
echo '</span> ';
echo '<p style="font-size:20px">';
echo $title = $_POST['text'];
echo "</p>";
?>
In PHP, all variable names begin with a dollar sign ($). The $ is followed by an
alphabetic character or an underscore, and optionally followed by a sequence of
alphanumeric characters and underscores. There is no limit on the length of a
variable name. Variable names in PHP are case-sensitive. Here are some examples:
$k
$cot
$Sar_name
$_MPS
In PHP, unlike in many other languages, you do not have to explicitly declare variables.
PHP automatically declares a variable the first time a value is assigned to it.
PHP variables are untyped; you can assign a value of any type to a variable.
PHP uses a symbol table to store the list of variable names and their values.
There are two kinds of symbol tables in PHP: the global symbol table, which stores
the list of global variables, and the function-local symbol table, which stores the
set of variables available inside each function.
Dynamic Variables
Sometimes it is useful to set and use variables dynamically. Normally, you assign a variable like this:
$var = "derro";
Now let's say you want a variable whose name is the value of the $var variable. You can do that like this:
$$var = "Jinna";
PHP parses $$var by first dereferencing the innermost variable, meaning that
$var becomes "derro". The expression that's left is $"hello", which is just $derro.
In other words, we have just created a new variable named hello and assigned it
the value "Jinna". You can nest dynamic variables to an infinite level in PHP,
although once you get beyond two levels, it can be very confusing for someone who
is trying to read your code.
dhoom 3 - back in action
PMA09:49
Dhoom 3 - back in action, most awaited bollywood movie watch trailers, promos,
wallpaper, news about movie and stars aamir khan, katrina kaif, bipasha basu.
Director vijay krishna acharya s dhoom 3 is doing well at the box-office the film
has grossed rs 101 crore in the first week at the box-office.dhoom 3 written and
directed by vijay krishna acharya and produced by aditya chopra.
Targeted Website Traffic
PMA18:59
Getting traffic online is very easy to do. The most important part about being successful online
is getting your website noticed. You should be spending most of your days promoting your site over
anything else in order to make money off of it.
I was once clueless about how to even create traffic online let alone even knowing what traffic meant.
Well, it has been about a year since I have been inthis online marketing business and has really
become my second nature.
Here I would like to share with you the simplest ways in which you can drive traffic to your site
immediately. Just remember the more things that youdo on the list below the better results you will
have with the traffic to your website. Hopefully after you are done reading threw this article you can
get busy on the promotion of your website.
Here are the few best ways to get traffic to your landing pages:
- Forum Participation
- Article Marketing
- Social Bookmarking
- Myspace
- Press Releases
- Classified Ads
- Viral Marketing
All of these forms of traffic combined can explode your sites traffic within days. When choosing the
proper sites in which you want to work with to create your traffic, make sure you choose the ones that
are highly ranked within Google. That way you can easily get first page results for your website. I ama
firm believer of article marketing myself. You don't necessarily have to use that form of traffic if
you don̢۪t want to but it will help you out in thelong run for creating many back links to your site.
Just always remember that consistency is always to best attitude to have when you have your own
business online. You have to stay devoted and on task when you are promoting your sites. Promotion is
the most important part about making money online. You can have the nicest website in the world but
it will never see the time of day if you never get the word out there that you are in business.
If you feel like you don't really have a startingpoint or you are not to sure on how to do the
above traffic generation techniques or if you wouldlike a guide on how to master in Internet Marketing
feel free to check out more of my articles.
is getting your website noticed. You should be spending most of your days promoting your site over
anything else in order to make money off of it.
I was once clueless about how to even create traffic online let alone even knowing what traffic meant.
Well, it has been about a year since I have been inthis online marketing business and has really
become my second nature.
Here I would like to share with you the simplest ways in which you can drive traffic to your site
immediately. Just remember the more things that youdo on the list below the better results you will
have with the traffic to your website. Hopefully after you are done reading threw this article you can
get busy on the promotion of your website.
Here are the few best ways to get traffic to your landing pages:
- Forum Participation
- Article Marketing
- Social Bookmarking
- Myspace
- Press Releases
- Classified Ads
- Viral Marketing
All of these forms of traffic combined can explode your sites traffic within days. When choosing the
proper sites in which you want to work with to create your traffic, make sure you choose the ones that
are highly ranked within Google. That way you can easily get first page results for your website. I ama
firm believer of article marketing myself. You don't necessarily have to use that form of traffic if
you don̢۪t want to but it will help you out in thelong run for creating many back links to your site.
Just always remember that consistency is always to best attitude to have when you have your own
business online. You have to stay devoted and on task when you are promoting your sites. Promotion is
the most important part about making money online. You can have the nicest website in the world but
it will never see the time of day if you never get the word out there that you are in business.
If you feel like you don't really have a startingpoint or you are not to sure on how to do the
above traffic generation techniques or if you wouldlike a guide on how to master in Internet Marketing
feel free to check out more of my articles.
Php-Associative Arrays
PMA08:24
Arrays are another basic structure in programming languages. Arrays provide means for
storing a fixed set (or collection) of the same datatype in a convenient way, making
each element of your set indexable by using a unique key.
In the typical "conventional" programming languages, arrays are handled like this:
int my_int_array[786]; // allocate 786 integers in this array
This C code snippet declares an array called my_integer_array, containing 256 integers.
You can address each of these integers by indexing the array with an ordinal value, for this array in a range from 0 to 255. (C starts counting from 0; the given number in the array definition specifies the number of integers you want to have available.) Indexing looks like this:
int my_integer = my_integer_array[4];
This retrieves the fifth element remember, C starts counting from 0 from the array
and stores it in my_integer.
Arrays for coding
Contents of Arrays can be stretched,
Arrays easily help group related information such as server login detailstogether
Arrays help write cleaner code.
Arrays are special variableswith the capacityto store multi values.
Arrays are flexibilityand can be easily stretchedto accommodate more values
Numeric arraysuse numbers for the array keys
Associative arraysuse descriptive namesfor array keys
Multidimensionalarrays contain other arrays insidethem.
The countfunction is used to get the numberof itemsthat have been stored in an array
The is_arrayfunction is used to determinewhether a variableis a valid array or not.
Other array functions include sort, ksort, assort etc.
Due to the nature of compiled languages, you were always bound to the previous
definition of your variables. If you suddenly needed more than 256 integers in the array above, this was impossible. Of course, you could have defined this variable as a pointer to an integer array and allocated 257 elements for it—but what if you suddenly needed another element? You'd have to allocate new space, copy the old array contents, and free up the old, unused space.
PHP takes a different approach. Because PHP knows no typical variable declarations only type definitions
), new variables are allocated on the fly. Whenever you create a new variable by introducing its
name into the namespace, you simply create storage space bound to this name—nothing more. The kind of data residing in this space is not restricted to a certain variable type. It can be reinterpreted on the fly, and of course resized, reallocated, whatever.
Take a look at this:
$my_var = 1;
$my_var = "Used to be an integer";
$my_var = array("Oh well, I like arrays better");
The first line creates a new variable $my_var.
PHP will find that an integer is going to be assigned to it; thus it sets the initial
type of $my_var to integer. The second line, however, overwrites the contents of $my_var
with a string. Using one of the conventional programming languages, this would have
resulted in an error at compile time, or at least an exception during runtime.
But PHP dynamically changes the type of $my_var to String and reallocates the variable
so that enough storage space for the string is available. The third line then changes
the type of $my_var once more by creating an array out of it. PHP handles all cases
transparently without complaining. (We know that other languages out there exist
without strict variable types.
Note: PHP 3.0 doesn't have proper garbage collection. When reallocating a variable,
memory that's already allocated is not always being reused. In long-term scripts or
scripts doing heavy processing.
Because formal variable declarations are not needed in PHP variable usage is completely
dynamic. A special case in PHP's dynamic variable handling is arrays. You probably
know the common array type, the indexed array. Indexed arrays are arrays that are
indexed by ordinal numbers. These ordinal indices typically range from 0 to n, n
being the highest possible index. Languages such as Pascal allow indexing with
different ranges such as from 3 to 18; however, these ranges are transformed back
to 0-based indexes at runtime. The key feature of these ordinally indexed arrays is
that you can compute another index from any given base index. For example, suppose
you want to read out three consecutive array elements, starting from index 2:
$base_index = 2;
for($i = $base_index; $i < $base_index + 3; $i++)
print("Element $i is $my_array[$i]<br>");
In every iteration of the for() statement, this little snippet computes the next
index into the array by incrementing $i.
Associative arrays don't have this feature. The special thing about associative arrays
is that they can be indexed with non-ordinal keys, such as strings, for example.
Every string used as an index has a value associated to it, thus the name associative arrays.
As you can imagine, giving a string as base index doesn't allow guessing the next valid index
in the array. Thus, associative arrays can't be used to order data elements in an ordinal way.
You have to know the array keys to retrieve their associated values.
Apart from that, the functions list() and each(), discussed earlier,
can be used to traverse associative arrays.
Indexed arrays are just a special form of associative arrays in PHP. Doing an unset() on
one of the elements in an indexed array will leave all other elements and their ordering
intact, but produce a nonconsecutive array. See the earlier descriptions of
list() and each() for details.
Multidimensional Arrays
As the name suggests, multidimensional arrays are arrays with more than just one dimension.
One-dimensional (or single-dimensional) arrays are the form in which arrays are mostly seen:
$my_array[0] = 1;
$my_array[1] = 777;
$my_array[2] = 45;
To index this type of array, you only need one index, which limits the number of possible
values to the range of this index. But it's often very useful to create multidimensional
arrays when handling complex datasets. Typical examples include bitmaps and screen buffers.
When you look at your monitor, you see at least these days a two-dimensional projection of
your desktop. The windows, bitmaps, command lines, cursors, pointers—everything is 2D.
To represent this data in a convenient way, you could of course serialize everything
into arrays with a single dimension—but the more appropriate method is to use arrays
with dimensions equal to those of the input data. For example, in order to store a bitmap
a set of pixels for a mouse pointer, you just add another index to your array:
// clear mouse bitmap
for($x = 0; $x < MOUSE_X_SIZE; $x++)
for($y = 0; $y < MOUSE_Y_SIZE; $y++)
$mouse_bitmap[$x][$y] = 0;
storing a fixed set (or collection) of the same datatype in a convenient way, making
each element of your set indexable by using a unique key.
In the typical "conventional" programming languages, arrays are handled like this:
int my_int_array[786]; // allocate 786 integers in this array
This C code snippet declares an array called my_integer_array, containing 256 integers.
You can address each of these integers by indexing the array with an ordinal value, for this array in a range from 0 to 255. (C starts counting from 0; the given number in the array definition specifies the number of integers you want to have available.) Indexing looks like this:
int my_integer = my_integer_array[4];
This retrieves the fifth element remember, C starts counting from 0 from the array
and stores it in my_integer.
Arrays for coding
Contents of Arrays can be stretched,
Arrays easily help group related information such as server login detailstogether
Arrays help write cleaner code.
Arrays are special variableswith the capacityto store multi values.
Arrays are flexibilityand can be easily stretchedto accommodate more values
Numeric arraysuse numbers for the array keys
Associative arraysuse descriptive namesfor array keys
Multidimensionalarrays contain other arrays insidethem.
The countfunction is used to get the numberof itemsthat have been stored in an array
The is_arrayfunction is used to determinewhether a variableis a valid array or not.
Other array functions include sort, ksort, assort etc.
Due to the nature of compiled languages, you were always bound to the previous
definition of your variables. If you suddenly needed more than 256 integers in the array above, this was impossible. Of course, you could have defined this variable as a pointer to an integer array and allocated 257 elements for it—but what if you suddenly needed another element? You'd have to allocate new space, copy the old array contents, and free up the old, unused space.
PHP takes a different approach. Because PHP knows no typical variable declarations only type definitions
), new variables are allocated on the fly. Whenever you create a new variable by introducing its
name into the namespace, you simply create storage space bound to this name—nothing more. The kind of data residing in this space is not restricted to a certain variable type. It can be reinterpreted on the fly, and of course resized, reallocated, whatever.
Take a look at this:
$my_var = 1;
$my_var = "Used to be an integer";
$my_var = array("Oh well, I like arrays better");
The first line creates a new variable $my_var.
PHP will find that an integer is going to be assigned to it; thus it sets the initial
type of $my_var to integer. The second line, however, overwrites the contents of $my_var
with a string. Using one of the conventional programming languages, this would have
resulted in an error at compile time, or at least an exception during runtime.
But PHP dynamically changes the type of $my_var to String and reallocates the variable
so that enough storage space for the string is available. The third line then changes
the type of $my_var once more by creating an array out of it. PHP handles all cases
transparently without complaining. (We know that other languages out there exist
without strict variable types.
Note: PHP 3.0 doesn't have proper garbage collection. When reallocating a variable,
memory that's already allocated is not always being reused. In long-term scripts or
scripts doing heavy processing.
Because formal variable declarations are not needed in PHP variable usage is completely
dynamic. A special case in PHP's dynamic variable handling is arrays. You probably
know the common array type, the indexed array. Indexed arrays are arrays that are
indexed by ordinal numbers. These ordinal indices typically range from 0 to n, n
being the highest possible index. Languages such as Pascal allow indexing with
different ranges such as from 3 to 18; however, these ranges are transformed back
to 0-based indexes at runtime. The key feature of these ordinally indexed arrays is
that you can compute another index from any given base index. For example, suppose
you want to read out three consecutive array elements, starting from index 2:
$base_index = 2;
for($i = $base_index; $i < $base_index + 3; $i++)
print("Element $i is $my_array[$i]<br>");
In every iteration of the for() statement, this little snippet computes the next
index into the array by incrementing $i.
Associative arrays don't have this feature. The special thing about associative arrays
is that they can be indexed with non-ordinal keys, such as strings, for example.
Every string used as an index has a value associated to it, thus the name associative arrays.
As you can imagine, giving a string as base index doesn't allow guessing the next valid index
in the array. Thus, associative arrays can't be used to order data elements in an ordinal way.
You have to know the array keys to retrieve their associated values.
Apart from that, the functions list() and each(), discussed earlier,
can be used to traverse associative arrays.
Indexed arrays are just a special form of associative arrays in PHP. Doing an unset() on
one of the elements in an indexed array will leave all other elements and their ordering
intact, but produce a nonconsecutive array. See the earlier descriptions of
list() and each() for details.
Multidimensional Arrays
As the name suggests, multidimensional arrays are arrays with more than just one dimension.
One-dimensional (or single-dimensional) arrays are the form in which arrays are mostly seen:
$my_array[0] = 1;
$my_array[1] = 777;
$my_array[2] = 45;
To index this type of array, you only need one index, which limits the number of possible
values to the range of this index. But it's often very useful to create multidimensional
arrays when handling complex datasets. Typical examples include bitmaps and screen buffers.
When you look at your monitor, you see at least these days a two-dimensional projection of
your desktop. The windows, bitmaps, command lines, cursors, pointers—everything is 2D.
To represent this data in a convenient way, you could of course serialize everything
into arrays with a single dimension—but the more appropriate method is to use arrays
with dimensions equal to those of the input data. For example, in order to store a bitmap
a set of pixels for a mouse pointer, you just add another index to your array:
// clear mouse bitmap
for($x = 0; $x < MOUSE_X_SIZE; $x++)
for($y = 0; $y < MOUSE_Y_SIZE; $y++)
$mouse_bitmap[$x][$y] = 0;





































