background preloader

Php

Facebook Twitter

Functions

Validation. Honeypot. Mysql_real_escape_string. PHP Thumbnailer | Gen X Design. Articles and Tutorials - Socket Programming With PHP. Doing A Deal If you've been working with PHP for a while, you're probably used to thinking about it only in the context of a Web page or a Web server. While this is not unusual - PHP is, after all, a scripting language that's most commonly used to dynamically generate Web pages - it can stifle your creativity; as you'll see in this article, there's a lot more you can do with PHP than just connect to a database, retrieve records and insert them into an HTML template.

One of PHP's better-guarded secrets - and one that I discovered quite by accident - is a very comprehensive set of network programming functions. Steadily evolving over the last few releases, this socket programming API now supports almost everything you would need for socket-based client-server communication over TCP/IP, and can be rapidly deployed to build simple client-server applications in PHP. In return for all this largesse, I expect you to laugh at the appropriate places, and say nice things about me to your friends. Php Tutorials by PhpTutorialSite.com » Working With Files Part Two. Tutorials | CodeIgniter. PHP Read Remote File. Design:php_and_uml_class_diagrams [phpPatterns] Easy IP to country lookup. PHP Login script.

String Functions. If you want a function to return all text in a string up to the Nth occurrence of a substring, try the below function. Works in PHP >= 5. (Pommef provided another sample function for this purpose below, but I believe it is incorrect.) <? Php function nsubstr($needle, $haystack, $n_occurrence) { $arr = explode($needle,$haystack,$n_occurrence); $last = count($arr) - 1; $pos_in_last = strpos($arr[$last],$needle); if ($pos_in_last !

$string = 'd24jkdslgjldk2424jgklsjg24jskgldjk24'; print 'S: ' . ? You will still have to make a conservative guess of the max number of characters per line with wordwrap(), but you can be more precise than if you were simply truncating a multiple-line string with substr(). See example: $text = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. $wrapped_text = wordwrap($text,100,'<br>',true); $three_lines = nsubstr('<br>',$wrapped_text,3); print '<br><br>' . $four_lines = nsubstr('<br>',$wrapped_text,4); print '<br><br>' . PHP Browser Detection and User Agent Sniffer. Extract Domain Name From Host Name In PHP. PHP techniques I use all the time. Back in February, I was writing CSS every day and I decided to share some of the CSS techniques that I always use.

Lately I've been writing more PHP than anything else and I've found myself using some very useful techniques all the time. Now I know that PHP isn't very "cool" these days; it's probably the most misunderstood web language because all the script kiddies use it to include files on their webpages and put up forms that get hacked hours later. But I think PHP deserves a whole lot more credit than it gets; it's fast, it integrates very nicely with Apache, it got all the right features in version 5, and even if you don't like using it, there's always a chance you might have to write some anyway. So, maybe these tips can help you out: Use heredoc syntax for strings: If there's one thing I got tired of fast, it was building long strings like this: If I am going to make a string with more than one line, and even sometimes when I'm not, then I use heredoc.

PHP Cheat Sheet - Cheat Sheets.