FAQ

Search Discussions

696 discussions - 1,124 posts

  • memcache has no locking mechanism, but you could implement it manually. basic locking through the add method: <?php // locks time out after 5 seconds Define( 'LOCK_TIMEOUT', 5 ); $lock = $memcache- ...
    PhpPhp
    Apr 3, 2008 at 4:30 pm
    Oct 22, 2013 at 8:01 am
  • function to replace all \n\n\n\n\n\n \r\r\r\r only one <br / function Only1br($string) { return preg_replace("/(\r\n)+|(\n|\r)+/", "<br / ", $string); } $string = "this is \n\n\n a String with many ...
    RphsmRphsm
    Apr 30, 2008 at 8:52 pm
    Jun 13, 2013 at 11:09 am
  • My simple work around. function my_round($value, $precision=0) { return round(round($value*pow(10, $precision+1), 0), -1)/pow(10, $precision+1); } ---- Server IP: 208.69.120.35 Probable Submitter: ...
    AlvedaAlveda
    Apr 20, 2008 at 7:06 am
    Dec 9, 2012 at 8:23 am
  • I'm new to PHP, coming from Perl and I already had a problem once when I wanted to join some strings. In perl you can use join to join a list (which can be an array and/or a list of strings and/or ...
    WesleysWesleys
    Apr 2, 2008 at 12:33 am
    Aug 2, 2012 at 1:20 pm
  • I ran into problems using the MEMCACHE_COMPRESSED flag when storing small amounts of data, such as an integers. For expample. Memcache::set('integer', 123456, MEMCACHE_COMPRESSED); //would return ...
    Stephenfromveedow ComStephenfromveedow Com
    Apr 9, 2008 at 2:04 pm
    Jun 19, 2010 at 3:58 am
  • The lowest byte of the int is reserved for pecl/memcache internal usage (e.g. to indicate compression and serialization status). ---- Server IP: 82.177.164.100 Probable Submitter: 217.153.66.146 ---- ...
    Jakub LopuszanskiJakub Lopuszanski
    Apr 14, 2008 at 2:43 pm
    Jun 19, 2010 at 3:58 am
  • I used shawn's code that is an ongoing fix/update of a very nice php 4 & 5 compatible class. It works great, only it kept giving me errors when the array isn't set, (I have errors set to show all). ...
    GalendotsenoglesatgmaildotcomGalendotsenoglesatgmaildotcom
    Apr 19, 2008 at 7:07 pm
    Mar 3, 2010 at 6:39 pm
  • You can use eval() to get around the limitation on using variable variables to reference superglobal arrays. e.g.: # this fails: function indir($name) { $moe = $$name; echo "<pre "; print_r($moe); ...
    FmouseFmouse
    Apr 29, 2008 at 9:35 pm
    Jun 24, 2009 at 4:43 pm
  • If you have to use a proxy to make requests outside of your local network, you may use this class: /* * * No Proxy Authentification Implemented; PHP 5 * */ class RemoteFopenViaProxy { private ...
    JabebaJabeba
    Apr 17, 2008 at 1:19 pm
    Jun 8, 2009 at 11:26 pm
  • Or even just function deltree($f) { if (is_dir($f)) { foreach(glob($f.'/*') as $sf) { if (is_dir($sf) && !is_link($sf)) { deltree($sf); } else { unlink($sf); } } } rmdir($f); } ...As we're already ...
    DavedxDavedx
    Apr 1, 2008 at 10:17 am
    Apr 15, 2009 at 4:18 am
  • I am having problems with the timhavens's <i dates_betweeen_dates()</i script not returning proper output for calls like: <? print_r(dates_between_dates('2008-04-14', '2008-04-14')); ...
    BrianBrian
    Apr 14, 2008 at 2:51 pm
    Aug 3, 2008 at 11:47 am
  • There is a problem to set a static function as error handler <?php class Debug { public static function test($num,$err,$file,$line) { return true; } } ? <?php set_error_handler(array(Debug,'test')); ...
    AlexeyletoshnikovAlexeyletoshnikov
    Apr 4, 2008 at 1:46 pm
    Aug 24, 2014 at 9:36 am
  • Java Like Array Implementation! <?php /* * Author : Pragash Jeyaratnam * Vector Class * PHP Version 5.2.5 * Contact : pragash_jey@yahoo.com. */ class Vector { /* * The number of valid components in ...
    Pragash_jeyPragash_jey
    Apr 6, 2008 at 2:35 pm
    May 6, 2014 at 9:57 pm
  • I thought it was pertinent to demonstrate just how slow the eval() function is when compared to pre-parsed code, so I wrote this. In my case, it took 54 seconds to execute the code 100,000,000 times ...
    LukeLuke
    Apr 2, 2008 at 8:24 am
    Dec 9, 2013 at 11:57 am
  • It seems that the Magic constants (http://www.php.net/manual/en/language.constants.predefined.php) do NOT work in an eval()'ed code. Probably because PHP substitutes these statically when it compiles ...
    IvanzaharievIvanzahariev
    Apr 2, 2008 at 9:08 am
    Dec 6, 2013 at 9:29 pm
  • An easy mistake some programmers from other languages might make is delimiting conditions for a case block by a comma: <? $val = "x"; switch ($val) { case "x", "y", "z": echo "Case is x, y or z"; ...
    JphansenJphansen
    Apr 11, 2008 at 6:31 pm
    Dec 2, 2013 at 9:04 am
  • For read a file from a bfile using OCI- LOB //any.jpg must be any file $image = new Imagick('any.jpg'); // rewind the OCI- lob $ociLob- rewind(); //This is the magick $image- readImageBlob($ociLob- ...
    FinalmauFinalmau
    Apr 29, 2008 at 11:18 pm
    Oct 22, 2013 at 8:01 am
  • hebrev/hebrevc does not support unicode strings. when using the GD lib and imagettftext() with hebrew text you must reverse the chars before sending it to the function. so there is a need for ...
    SocketSocket
    Apr 29, 2008 at 7:54 pm
    Oct 22, 2013 at 8:01 am
  • flush() will prevent headers from being sent. <?php flush(); header('Location: testj.php'); ? Warning: Cannot modify header information - headers already sent in testk.php on line 3 ---- Server IP: ...
    MarquesMarques
    Apr 10, 2008 at 5:20 pm
    Oct 22, 2013 at 8:01 am
  • "post_max_size" "[..]This can be tracked in various ways, e.g. by passing the $_GET variable to the script processing the data, i.e. <form action="edit.php?processed=1" , and then checking if ...
    Senf_glasSenf_glas
    Apr 9, 2008 at 11:29 am
    Oct 22, 2013 at 8:01 am
  • Here is a function that wraps htmlspecialchars and makes it work for xml. function xmlspecialchars($text) { return str_replace('&#039;', '&apos;', htmlspecialchars($text, ENT_QUOTES)); } ---- Server ...
    TreyhTreyh
    Apr 9, 2008 at 6:38 pm
    Oct 22, 2013 at 6:47 am
  • Hi all: I found this and maybe it can help you, i didn't found it documented anywhere : Assuming you have a function that returns an array or a null value in failure and you do something like this ...
    JescribensJescribens
    Apr 4, 2008 at 5:10 pm
    Oct 22, 2013 at 6:42 am
  • Re requiring to escape the forward slash: I think PHP 5.2.1 had that problem, as I remember it occurring here when I posted that comment; but now I'm on 5.2.5 it doesn't, so it has obviously been ...
    PhpbenPhpben
    Apr 16, 2008 at 7:15 am
    Jun 14, 2013 at 10:03 am
  • As a response to Anonymous on 28-Dec-2007 07:25, please, remember that creating lots of MyXExtension classes is wrong if and only if your object oriented model is not well designed. One should (I ...
    I Crash17I Crash17
    Apr 5, 2008 at 4:48 am
    Jan 19, 2013 at 3:44 am
  • If you're having trouble installing the Tidy2 extension on Ubuntu Dapper for PHP 5, take a look at this thread in the support forums: http://ubuntuforums.org/showthread.php?t=195636 In summary: * ...
    SpacemanSpaceman
    Apr 13, 2008 at 4:59 pm
    Jan 17, 2013 at 3:43 pm
  • Excample : <?php function if_this_an_int($arg) { if(strlen($arg) 0 && is_numeric($arg) && $arg 0) { echo round($arg); } } $test = 1.3; echo if_this_an_int($test); ? You can use this function for any ...
    ThomasThomas
    Apr 16, 2008 at 11:29 am
    Dec 9, 2012 at 8:23 am
  • For your convenience, here's an example of how to set the error handling: <?php $dbh = new PDO( /* your connection string */ ); $dbh- setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING ); // . . . ...
    RadicalRadical
    Apr 22, 2008 at 7:42 pm
    Oct 22, 2012 at 8:15 am
  • Here's yet another way to make a list()-like construct for associative arrays. This one has the advantage that it doesn't depend on the order of the keys, it only extracts the keys that you specify, ...
    TristaninoregonTristaninoregon
    Apr 9, 2008 at 2:42 am
    Sep 13, 2012 at 10:03 am
  • Here is a quick and easy way to get the base name and the extension of a file. I noticed that many examples here use explode(...), however this doesn't handle filenames like foo-1.0.1.tar gracefully. ...
    DevDev
    Apr 2, 2008 at 6:42 am
    Aug 22, 2012 at 1:52 am
  • admin at semaster dot ru's array_trim function is flawed in that it will change the type of nulls and numeric variables (to strings). Here is a better version, although it lacks charlist support: ...
    MeMe
    Apr 16, 2008 at 11:47 pm
    Aug 2, 2012 at 12:26 pm
  • Another way to preview a text with or without html tags, and end not cut in a middle of a word. <?php function preview_text($TEXT, $LIMIT, $TAGS = 0) { // TRIM TEXT $TEXT = trim($TEXT); // STRIP TAGS ...
    Radu_keepwalkingRadu_keepwalking
    Apr 15, 2008 at 11:34 am
    Aug 2, 2012 at 12:15 pm
  • The paragraph on code protection is somewhat misleading. While it is correct that the exact source code can not be recreated this does not offer anything in terms of code protection and lures people ...
    AnonymousAnonymous
    Apr 16, 2008 at 9:52 pm
    Nov 28, 2011 at 11:45 am
  • On response to slimshady451: hash_file( 'crc32', $file ) will not have the same return of crc32( file_get_contents( $file ) ) ---- Server IP: 69.147.83.197 Probable Submitter: 201.87.29.218 ---- ...
    GuilhermeGuilherme
    Apr 8, 2008 at 9:00 pm
    Oct 6, 2011 at 9:19 pm
  • In addition to reiner-keller's comment about Umlaute using setlocale (LC_ALL, 'de_DE'); To enable 'de_DE' on my Debian 4 machine I first had to: - uncomment 'de_DE' in file /etc/locale.gen and ...
    GeorgGeorg
    Apr 4, 2008 at 9:33 am
    Aug 3, 2011 at 1:09 pm
  • I found that in order to get .NET to match an MD5 with the PHP md5 function you need to use a UTF7 encoding. See http://ok-cool.com/posts/read/125-php-md5-not-the-same-as-net-md5/ for more details. ...
    TaholderTaholder
    Apr 23, 2008 at 9:29 pm
    Jul 18, 2011 at 1:54 pm
  • @Kevin Campbell: Yep, be carefull....the docu is misleading.... $beginning = 'foo'; $end = array(0 = 'bar'); $result = array_merge((array)$beginning, (array)$end); print_r($result); will produce: ...
    NoNo
    Apr 3, 2008 at 2:28 pm
    Jun 20, 2011 at 3:24 pm
  • $result[] = array( 'storeid' = '1', 'testid' = '101' ); $result[] = array( 'storeid' = '2', 'testid' = '102' ); print_r($result); $row['storeid'] = '9'; $row['testid'] = '900'; $query = 'INSERT INTO ...
    CharliesmithCharliesmith
    Apr 21, 2008 at 6:27 pm
    May 17, 2011 at 6:09 pm
  • According to the discussion associated with bug #17538, the "termination status" as returned by this function is not the same thing as the exit code ($? in BASH). To extract the exit code from the ...
    NonameNoname
    Apr 2, 2008 at 8:42 pm
    May 17, 2011 at 2:44 pm
  • This example of the heredoc has wrong output: Code: This should print a capital 'A': \x41 Output should be: This should print a capital 'A': A The example of the nowdoc has wrong code: Code: This ...
    YukuYuku
    Apr 1, 2008 at 2:18 am
    May 17, 2011 at 2:41 pm
  • <?php $F = "F"; function F($s) { return $s; } $filename = '<some code '; echo "{$F(htmlspecialchars($filename))}"; ? ---- Server IP: 209.41.74.194 Probable Submitter: 138.23.21.189 ---- Manual Page ...
    Sk89qSk89q
    Apr 30, 2008 at 7:42 pm
    May 17, 2011 at 2:40 pm
  • In a publication by WROX I noted a variant of the earlier "bound" function: A parameter had to be between 1 and 3... $par=round((min(max($x,1),3)); ---- Server IP: 117.104.160.194 Probable Submitter: ...
    HenkHenk
    Apr 16, 2008 at 7:03 am
    Mar 22, 2011 at 1:47 pm
  • I liked what Jonas Lindel�v suggested (below) and added a bit more to it: Removes the $_POST data and puts it in the session to avoid the F5 <refresh msg that browsers give If $_POST data is ...
    WayneWayne
    Apr 11, 2008 at 11:49 am
    Mar 9, 2011 at 2:24 pm
  • With OSX 10.5, the bundled version is up to date but didn't come with the modules I needed (notably I wanted the pgsql database extension). Getting this to work was quite simple in the end, what made ...
    MdoyleMdoyle
    Apr 7, 2008 at 2:52 pm
    Jan 28, 2011 at 2:22 pm
  • Comments don't have to have an entire line dedicated to them. You can put a comment on the same line as a section or variable/value declaration and the built-in parse_ini_file() function will omit ...
    Asohn~at~aircanopy~dot~netAsohn~at~aircanopy~dot~net
    Apr 30, 2008 at 10:24 pm
    Jan 23, 2011 at 5:01 pm
  • You can also use strrchr() to get the file extension, it produces the same result as the post below mine... i.e. file_ext = strrchr($filename, '.'); This gets the string after the last occurrence of ...
    BokiatenxiBokiatenxi
    Apr 4, 2008 at 3:54 am
    Jan 23, 2011 at 4:52 pm
  • This is an extension to Mattlock's Singleton class and interface. It has a number of advantages: 1) It uses a single abstract class instead of an interface and class definition, which to me is ...
    ChrisChris
    Apr 18, 2008 at 2:08 pm
    Jan 23, 2011 at 4:32 pm
  • I cannot belive I was so stupid with my first note on this... As any Singleton class forces a design pattern on to the user, and is really just a helper class for that design pattern, there is no ...
    ChrisChris
    Apr 18, 2008 at 4:08 pm
    Jan 23, 2011 at 4:32 pm
  • Using the decrypt funciont of the Pear class Crypt_Blowfish, the decrypted text must be cleaned from null characters (this happen when the text size is not a multiple of the cbc block size). So the ...
    Matrix EpokhMatrix Epokh
    Apr 21, 2008 at 5:18 am
    Dec 13, 2010 at 4:13 pm
  • Note that the official data URI scheme does not include a double slash after the colon - that you must include it when making calls to PHP is an artifact of the designers' misunderstanding of URL ...
    Togos00Togos00
    Apr 8, 2008 at 7:53 pm
    Nov 18, 2010 at 12:34 pm
  • Seems, that json_encode make some cuts with float type values: echo json_encode(1234567890.1234567890); // return 1234567890 echo json_encode(1234567.1234567890); // return 1234567.12 echo ...
    ElarElar
    Apr 1, 2008 at 4:18 pm
    Sep 18, 2010 at 3:38 pm
Group Navigation
period‹ prev | Apr 2008 | next ›
Group Overview
groupphp-notes @
categoriesphp
discussions696
posts1,124
users549
websitephp.net

549 users for April 2008

Felipe: 160 posts Nlopess: 136 posts Anonymous: 56 posts Sixd: 51 posts Philip: 45 posts : 27 posts Tularis: 25 posts Betz: 23 posts Kevin: 4 posts Phpdoc: 4 posts Charleslynch: 4 posts Jani: 4 posts Ezyang: 4 posts Darko: 3 posts Mail: 3 posts Hayleywatson: 3 posts Joachimb: 3 posts Alx: 3 posts Bladescope: 3 posts Lucianoropero: 3 posts
show more
Archives