FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


some usefull PHP functions





s_man
String manipulation functions in any programming language are the most commonly used functions by developers. So, I have decided to give few functions that might be useful for you as PHP developer.

bool ctype_alpha(mixed c) checks if the string contains only alphabetical characters

Example

ctype_alpha("WE2007") returns false because it alphanumeric
ctype_alpha("HELLO") returns True because it contains alphabetical charchaters only

bool ctype_digit(mixed c) checks if the string is valid number

Example

ctype_digit("RF334") returns false
ctype_digit("1533") returns True

bool ctype_xdigit(mixed c) checks if the string is valid hexadecimal number

Example

ctype_xdigit("RFJHFA3") returns false
ctype_xdigit("15BF") returns True

Note : that valid Hex numbers are 0 1 2 3 4 5 6 7 8 9 A B C D E F


All of the above functions supported by PHP version 4.0.4 or higher
sush
What function can be used to read text from a file and display it inline on an HTML page?
PseudoKnight
You could do a simple include in some cases.

include 'file.txt';

It depends on the formatting of the content in the text file and how you want to display. You may need to read the file, process the content, and then display the result. That could be something simple like this to use proper line breaks:

$var1 = file('file.txt');
$var2 = implode('', $var);
print nl2br($var2);

... or numerous other possibilities depending on your needs.
Related topics
req: PHP to list files in directory, and link to them
Great php editor
Tutorial: PHP Installed Modules Dynamic Reference Tool
PHP Tutorials
Enabled PHP Methods
A very good PHP MySQL Tutorial
Need a forum signature script, (php functions req)
PHP.ini
php / javascript script works in FireFox browser, but not IE
Using Javascript to Encrypt Data then POST to PHP
2 php functions disabled on Server 2
PHP Functions...
php functions
Need a PHP expert or Wordpress wizard
Reply to topic    Frihost Forum Index -> Computers -> Software

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.