FAQ

Search Discussions

600 discussions - 895 posts

  • I was working on using php to interface with an authorize.net gateway, and I ran into a problem with certificates using curl to talk the https:// url. curl_error() told me "SSL certificate problem, ...
    PyroeviPyroevi
    Nov 22, 2006 at 6:30 pm
    Mar 18, 2014 at 5:45 am
  • If you try to use it with Oracle Instant Client 10.2.0.2 on Windows 2003 Server, you might be getting the PHP Startup: Unable to load dynamic library 'C:\php\ext\php_oci8.dll' - The specified module ...
    AndreikubarAndreikubar
    Nov 26, 2006 at 3:50 pm
    Dec 7, 2009 at 9:33 pm
  • So I wanted a little function to output an easy to read but inaccurate date. I came up with the following (probably very inefficient) little function; <?php function ezDate($d) { $ts = time() - ...
    BanditBandit
    Nov 7, 2006 at 1:02 am
    Dec 14, 2014 at 11:32 am
  • /** * Converts a date string from one format to another (e.g. d/m/Y = Y-m-d, d.m.Y = Y/d/m, ...) * * @param string $date_format1 * @param string $date_format2 * @param string $date_str * @return ...
    JackJack
    Nov 26, 2006 at 9:52 pm
    Feb 9, 2012 at 9:03 pm
  • Same idea as below, but this: foreach( $args as $k = $v ){ switch($k){ case 'a': $this- a= $v; break; case 'b': $this- b= $v; break; case 'c': $this- c= $v; break; } } can be shortened to this (as ...
    Php-generalPhp-general
    Nov 1, 2006 at 6:23 am
    Jul 15, 2011 at 9:05 am
  • If you're looking for an easy way to create an attribute with a certain value, in a similar to createElement() manner, you should use the setAttribute() instead. Documentation and example is ...
    Boen RobotBoen Robot
    Nov 12, 2006 at 6:40 pm
    Apr 4, 2011 at 2:11 pm
  • dirlst - function to get directory and subdirectory file listing. Function outputs an array with filenames and optionally also their mod.time and/or size. You can choose also whether to include ...
    SkyeyeSkyeye
    Nov 30, 2006 at 10:34 pm
    Jan 28, 2010 at 2:00 pm
  • This script splits a text into portions of a defined max. size, which will never be exceeded, and doesnt cut words. (Per portion it adds as many words as possible without exceeding the char-limit) ...
    MeMe
    Nov 14, 2006 at 1:52 pm
    May 27, 2009 at 1:44 pm
  • Of course, all of this is moot if you use the new (pdp 5.1) DBO class and DBO::prepare($sql) with bound variables that protects against sql injection. ---- Server IP: 216.194.113.175 Probable ...
    DbrucasDbrucas
    Nov 21, 2006 at 6:40 pm
    Mar 14, 2009 at 3:03 pm
  • <?php if ( ! function_exists ( 'mime_content_type ' ) ) { function mime_content_type ( $f ) { return trim ( exec ('file -bi ' . escapeshellarg ( $f ) ) ) ; } } ? i used this one someone else posted ...
    Hillius EttinoffeHillius Ettinoffe
    Nov 24, 2006 at 9:34 am
    Jan 7, 2007 at 1:00 am
  • It appears that the restriction of calling stat() (and all dependent functions such as file_exists(), is_dir(), etc) on URL wrappers before PHP 5 also applies to custom stream wrappers registered ...
    ZimzatZimzat
    Nov 12, 2006 at 5:41 pm
    Nov 12, 2006 at 6:33 pm
  • An improvement to the array_deep_copy function I posted ages ago which takes a 'snapshot' of an array, making copies of all actual values referenced... Now it is possible to prevent it traversing the ...
    ElkabongElkabong
    Nov 13, 2006 at 11:39 am
    May 6, 2014 at 10:04 pm
  • In response to prauscher at gmx dot net: As tcknetwork wrote earlier, if you try to access a file from a destructor, you have to be aware that you are probably in the webservers root directory, ...
    RobertRobert
    Nov 12, 2006 at 8:44 pm
    Mar 18, 2014 at 2:12 am
  • as reported in bug 34206 the working dir is changed to the server root the best workaround is <?php class Foo { public function bar() { $this- _cwd = getcwd(); } public function __destruct() { ...
    Maniac_warlordatwebdotdeManiac_warlordatwebdotde
    Nov 4, 2006 at 12:47 pm
    Mar 18, 2014 at 2:12 am
  • This function can search in multidimensional arrays, no mather how multidimensional the array is! <?php function array_search(&$array,$needle) { foreach($array as $key = $value) { if($value == ...
    Evert_18Evert_18
    Nov 13, 2006 at 2:15 pm
    Feb 24, 2014 at 10:41 pm
  • And two more similar functions for encrypting and decrypting cookies: <?php function encryptCookie($value){ if(!$value){return false;} $key = 'The Line Secret Key'; $text = $value; $iv_size = ...
    DavidwhthomasatgmailDavidwhthomasatgmail
    Nov 29, 2006 at 8:38 pm
    Nov 9, 2013 at 11:11 am
  • Yet another implementation of array_product() using PHP's native array_reduce(): if (! function_exists('array_product')) { function array_product($array) { if (is_array($array)) { return (0 == ...
    BishopBishop
    Nov 30, 2006 at 3:09 am
    Oct 22, 2013 at 2:59 pm
  • If php_flag magic_quotes_gpc off does not work Use php_value magic_quotes_gpc off insteadin your .htaccess file ---- Server IP: 64.71.164.2 Probable Submitter: 71.252.235.175 ---- Manual Page -- ...
    Sunrunner20Sunrunner20
    Nov 25, 2006 at 3:06 am
    Oct 22, 2013 at 2:59 pm
  • Hint: setting the PDO::ATTR_ERRMODE attribute to PDO::ERRMODE_EXCEPTION worked for me only with Mysql 4.x - I took me some time to figure this out ;-) ---- Server IP: 212.124.37.9 Probable Submitter: ...
    TobiTobi
    Nov 20, 2006 at 11:08 pm
    Oct 22, 2013 at 2:59 pm
  • Since, so many people reused array_sorter class, I decided to put here some updated version with fixes. <?php // // $Id: array_sorter.inc.php 82 2005-11-17 17:14:39Z aleczapka $ // /** * Handles ...
    AleczapkaatgmxdotnetAleczapkaatgmxdotnet
    Nov 14, 2006 at 8:10 am
    Oct 22, 2013 at 2:59 pm
  • I don't really know what I'm doing, so I just stole various parts of this from other people around here and did a little improvising on my own. Hope this is helpful to somebody. This script allows ...
    DerekDerek
    Nov 14, 2006 at 4:26 am
    Oct 22, 2013 at 2:59 pm
  • How to get at multiple MySQL databases from PHP while continuing to hide the user credentials in Apache configuration files. (This builds on my solution to the problem of hiding such credentials that ...
    Graham_ruleGraham_rule
    Nov 10, 2006 at 9:56 pm
    Oct 22, 2013 at 6:53 am
  • At the top of your page, do something to this effect: <?php $n = "\n"; $t = "\t"; ? Then, if you need your table cell four tabs in: <?php echo($t . $t . $t . $t . '<td whatever</td ' . $n); ? This ...
    FloppieFloppie
    Nov 15, 2006 at 5:06 pm
    Jul 8, 2013 at 10:51 am
  • The JSON function is basically a more widely accepted variation on the WDDX principle: http://us2.php.net/manual/en/ref.wddx.php ---- Server IP: 64.71.164.2 Probable Submitter: 24.215.198.87 ---- ...
    MaxheadroomMaxheadroom
    Nov 11, 2006 at 11:46 pm
    Feb 11, 2013 at 5:17 am
  • I know there has been alot of remote filesize snippets posted, but I'll post mine also. It supports HTTP/HTTPS/FTP/FTPS and detects which type it should use. It needs --enable-ftp for the FTP/FTPS ...
    JoshFinlayJoshFinlay
    Nov 12, 2006 at 8:19 am
    Jan 22, 2013 at 12:21 am
  • See also property_exists() which allows detection of protected variables existing in a class even if they are NULL. ---- Server IP: 66.163.161.117 Probable Submitter: 58.105.232.4 ---- Manual Page -- ...
    PhpPhp
    Nov 29, 2006 at 11:11 pm
    Jan 19, 2013 at 3:48 am
  • As Seth mentions, when a user clicks reload or goes back with the browser button, data sent to the server, may be sent again (after a click on the ok button). It might be wise, to let the server ...
    SvendkSvendk
    Nov 9, 2006 at 3:58 am
    Jan 15, 2013 at 4:48 am
  • When I serialized an object and looked into resulting string, I mentioned that all private properties' names were prefixed by class name. This code: <?php class myclass { private $priv1 = "val1", ...
    AdminAdmin
    Nov 19, 2006 at 4:21 pm
    Nov 6, 2012 at 2:11 am
  • for those who has error like " error at offset .." but doesn't know why. This function might be usefull <?php $sObject3 = 'a:2:{i:0;s:1:"1";i:1;s:3654:"1a1dc91c907325c69271ddf0c944bc72";}'; print_r( ...
    GetmequickatgmaildotcomGetmequickatgmaildotcom
    Nov 20, 2006 at 11:18 am
    Nov 6, 2012 at 1:28 am
  • Apparently, unserialize is really picky about anyone messing with the serial string. Just spent an hour debugging why unserialize wasn't working on a serial string stored in a database where, per ...
    EakolbEakolb
    Nov 2, 2006 at 4:27 pm
    Nov 6, 2012 at 1:28 am
  • @ thorerik dot lie at gmail dot com <? $array=gd_info (); foreach ($array as $key= $val) { if ($val===true) { $val="Enabled"; } if ($val===false) { $val="Disabled"; } echo "$key: $val <br / \n"; } ? ...
    BaumbachatkabecedotcomBaumbachatkabecedotcom
    Nov 3, 2006 at 4:55 pm
    Oct 5, 2012 at 2:42 pm
  • <?php /** * strip_selected_tags ( string str [, string strip_tags[, strip_content flag]] ) * --------------------------------------------------------------------- * Like strip_tags() but inverse; the ...
    DavidDavid
    Nov 5, 2006 at 7:26 pm
    Sep 20, 2012 at 12:01 pm
  • I ran the follow script and found that using "$var" was 'mostly' slower than using ' '.$var <?php $var = 1; for( $x=0; $x < 101; $x++ ) { echo '<br / <br / var = int( '.$var.' )<br / '; $timer- ...
    KevinKevin
    Nov 10, 2006 at 2:54 am
    Aug 2, 2012 at 3:17 pm
  • Jonathon Reinhart's neat little function to find out if a value is odd or even doesn't work for floats (this might possibly arithmetically correct but causes the following problem) eg <?php 12.23 % 2 ...
    Jon_rhoadesJon_rhoades
    Nov 27, 2006 at 12:45 pm
    Aug 2, 2012 at 3:06 pm
  • An easier way of doing alternating row colors is just setting the first row color outside of your loop, calling your loop, and then calling the class or hex code into a single spot, rather than ...
    SeanSean
    Nov 6, 2006 at 11:58 pm
    Aug 2, 2012 at 3:05 pm
  • The english_list() implementation of davidpk212 at gmail dot com, Andy Morris, and tshort at cisco dot com does not handle the case of a two-element array with Oxford comma. Example: <?php ...
    BishopBishop
    Nov 23, 2006 at 2:49 pm
    Aug 2, 2012 at 1:17 pm
  • This is a simple function that is the same as implode except it allows you to specify two glue parameters instead of one so an imploded array would output "this, this, this and this" rather than ...
    RichardRichard
    Nov 23, 2006 at 12:39 pm
    Aug 2, 2012 at 1:17 pm
  • As response to Ella's note: $array[0] = 'record1'; $array[9] = 'record2'; $array[15] = 'record3'; That is ordered way easier AND faster with array_values(). array_reverse twice is unnecessary. Once ...
    RdxatjouwmoederRdxatjouwmoeder
    Nov 7, 2006 at 11:34 am
    Jun 8, 2012 at 8:27 pm
  • if you are sending your data to a database, you can just send time() and then use strftime() to turn the time() string into readable time format. check both time() and strftime() functions both offer ...
    Php-generalPhp-general
    Nov 28, 2006 at 7:23 pm
    Feb 9, 2012 at 9:03 pm
  • The decipherment does the character encoded by the escape function of JavaScript. When the multi byte is used on the page, it is effective. javascript escape('aaああaa') ..... 'aa%u3042%u3042aa' ...
    JojoJojo
    Nov 4, 2006 at 4:24 am
    Jan 10, 2012 at 8:12 pm
  • You should always hash the password with the username, so store md5($password . $username) instead of md5($password) This way the cracker cannot use a precomputed set of hashes of common keys, but ...
    KetosKetos
    Nov 3, 2006 at 12:02 am
    Dec 28, 2011 at 8:42 am
  • Here is a faster and tested version of strip_selected_tags. Previous example had a small bug that has been fixed now. <?php function strip_selected_tags($text, $tags = array()) { $args = ...
    BermiferrerBermiferrer
    Nov 27, 2006 at 9:59 am
    Sep 23, 2011 at 3:58 pm
  • While function ncurses_nodelay() is still not implemented and if you need a non-blocking getch, following code might help. $init = ncurses_init(); $full = ncurses_newwin (0,0,0,0); ...
    PetrathrochdotinfoPetrathrochdotinfo
    Nov 14, 2006 at 10:07 am
    Aug 18, 2011 at 4:46 pm
  • In the same way "define()" can be used to create a GLOBAL constant that can be assigned as the value of a CLASS constant (like anonymous (31-May-2006 10:03) noted a few posts back), MAGIC constants ...
    Lucas SLucas S
    Nov 7, 2006 at 2:06 am
    Aug 3, 2011 at 1:26 pm
  • In response to anon on 31-May-2006 02:03: If you can define a global constant based on the return of a function, please explain why you do not see it justifiable that a class constant should be able ...
    KevinKevin
    Nov 10, 2006 at 9:28 pm
    Aug 3, 2011 at 1:26 pm
  • Agreed, tszming at gmail dot com. I did my own test using simple (letters) and complex (letters, numbers, symbols) strings of short, (6 characters), medium (a sentence), and long (three paragraphs) ...
    NicholasNicholas
    Nov 15, 2006 at 6:31 am
    Jul 18, 2011 at 1:55 pm
  • <? //safe_glob() by BigueNique at yahoo dot ca //Function glob() is prohibited on some servers for security reasons as stated on: //http://seclists.org/fulldisclosure/2005/Sep/0001.html //(Message ...
    BigueniqueBiguenique
    Nov 11, 2006 at 4:11 am
    Jun 20, 2011 at 3:29 pm
  • An easier way to get the last key: $lastkey = end(array_keys($arr)); ---- Server IP: 64.71.164.2 Probable Submitter: 24.249.154.162 ---- Manual Page -- http://www.php.net/manual/en/function.end.php ...
    JohnnyJohnny
    Nov 3, 2006 at 2:42 pm
    Jun 15, 2011 at 11:01 pm
  • have found something interesting. when I use a FOREACH with the WHILE statement inside it as talk has been going on, it will give you all of the values of a multi-dimensional array. like this <?php ...
    Bleach984Bleach984
    Nov 10, 2006 at 1:39 am
    Feb 18, 2011 at 3:57 pm
  • When messing with custom headers, it is extremely helpful to make sure that they are actually sent to the server. Nothing is more frustrating than discovering that some custom header was improperly ...
    CustomizeitCustomizeit
    Nov 7, 2006 at 5:40 pm
    Jan 23, 2011 at 5:26 pm
Group Navigation
period‹ prev | Nov 2006 | next ›
Group Overview
groupphp-notes @
categoriesphp
discussions600
posts895
users506
websitephp.net

506 users for November 2006

Nlopess: 88 posts Bobby: 63 posts Php-general: 37 posts Tularis: 36 posts : 32 posts Aidan: 28 posts Colder: 24 posts Derick: 19 posts Betz: 15 posts Mazzanet: 14 posts Bjori: 5 posts Phpdoc: 4 posts David: 4 posts Torch: 3 posts Elwinvanhuissteden: 3 posts Chris: 3 posts Bishop: 3 posts Richard: 3 posts Andreagiammarchi: 3 posts Dwalton: 3 posts
show more
Archives