PHP is an HTML-embedded scripting language. It is an open source project. PHP also offers built-in database integration for several commercial and non-commercial database management systems, so writing a database-enabled webpage with PHP is fairly simple.
By default PHP is installed on Unix like operating system. The syntax is as follows to compare two strings using php:
<?php $string1 = "Foo"; $string2 = "Bar"; if ( $string1 == $string2 ){ echo "Equal: Yes\n"; } else{ echo "Equal: No\n"; } ?>
PHP version 4 and 5 comes with a new function called strcmp(). It is a binary safe string comparison function. The syntax is:
int strcmp ($string1, $string2);
The function returns the following values:
- Returns < 0 if string1 is less than string2.
- Returns > 0 if string1 is greater than string2.
- Returns 0 if they are equal.
Example
<?php $string1 = "Foo"; $string2 = "Bar"; if ( strcmp ( $string1, $string2) == 0 ){ echo "Equal: Yes\n"; } else{ echo "Equal: No\n"; } ?>
Another simple example:
$type=$what; $catoutput="NULL"; foreach( $cats as $key=>$values ){ $mycat=$values[0]; $myimg=$values[1]; $mydesc=$values[2]; if ( $key == $type ) { $catoutput = 'Plan: '. $mycat; $catoutput .= 'Image: ' . $myimg; $catoutput .= 'Description: ' . $mydesc; return $catoutput; } }
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop












{ 0 comments… add one now }