FAQ

Search Discussions

452 discussions - 834 posts

  • Before version 5.3 DateTime loses the value if it's serialized. Here's a fix: class Serializable_DateTime extends DateTime { private $_serializedValue; public function __wakeUp() { ...
    Carlos ViniCarlos Vini
    Aug 24, 2011 at 6:19 pm
    Aug 25, 2011 at 7:28 pm
  • Re: Note by vedran-b at email dot htnet dot hr I don't know what he managed to do, but under normal circumstances bind_param() does NOT by itself alter the value of the variables passed as arguments. ...
    AnonymousAnonymous
    Aug 18, 2011 at 2:05 pm
    Aug 18, 2011 at 4:42 pm
  • leading zero´s are easier to do with some small if statement $number = 123.3; $number = explode(".",$number); if(substr($number[1],1,1) == ""){ $number[1] = $number[1] . "0"; } $number = $number[0]. ...
    T UlrichT Ulrich
    Aug 29, 2011 at 12:43 pm
    Mar 23, 2014 at 2:12 pm
  • When __DIR__ is not defined, prior 5.3.0: if ( !defined('__DIR__') ) define('__DIR__', dirname(__FILE__)); ---- Server IP: 80.64.47.13 Probable Submitter: 83.56.148.235 ---- Manual Page -- ...
    Jrivero24Jrivero24
    Aug 5, 2011 at 9:34 am
    Oct 22, 2013 at 6:45 am
  • Function for resolved a Apache GetText Caching on developpement without restart Apache if you modify your po/mo files. public function translation() { if (GETTEXT_CACHING == 0) { $targetFolder = ...
    Laurent DefoerLaurent Defoer
    Aug 16, 2011 at 11:12 am
    Aug 19, 2013 at 5:58 pm
  • IMPORTANT NOTE: If you were used to using code like this: while(false !== ($row = mysql_fetch_assoc($result)) { ... } You must change it to this for mysqli: while(null !== ($row = ...
    James PhxJames Phx
    Aug 12, 2011 at 12:54 am
    Apr 14, 2013 at 7:11 pm
  • Hmm, using eval without proper escaping of the input value .. will not get you anything good ;) Here is my JSON decode function, it does not decode to PHP object/array but only to an array (can be ...
    Dragos UDragos U
    Aug 5, 2011 at 1:49 pm
    Nov 30, 2012 at 5:45 am
  • There seems to be some odd behavior when writing a query then reading it back in very quickly. I found it useful to ensure "safe" was set to true in order to stop random "'MongoCursorException' with ...
    RobRob
    Aug 20, 2011 at 7:11 am
    Nov 29, 2012 at 1:04 pm
  • Combined filter and trim array. function _trim_value(&$value) { if (is_string($value)) $value = trim($value); } function array_filter_and_trim($arr) { array_walk($arr, '_trim_value'); return ...
    LeahayesLeahayes
    Aug 10, 2011 at 12:19 pm
    Aug 2, 2012 at 12:32 pm
  • Be carfull after the day 28 of the month ! $month = 1; $year = 2011; $day = 27; $mkdate = date("Y-m-d", mktime(0, 0, 0, $month+1, $day, 2011)); echo 'date : ' . $mkdate .'<br / ';// TRUE the good ...
    ParazoomParazoom
    Aug 31, 2011 at 8:00 am
    Sep 5, 2011 at 12:54 pm
  • http://de2.php.net/security/crypt_blowfish.php details three salt præficÄ“s for the blowfish hash – but which of them matches the original, proper OpenBSD implementation¹ now (if any of them ...
    TgTg
    Aug 25, 2011 at 8:41 am
    Aug 25, 2011 at 6:55 pm
  • Simulate multiple threads request: <?php function multiple_threads_request($nodes){ $mh = curl_multi_init(); $curl_array = array(); foreach($nodes as $i = $url) { $curl_array[$i] = curl_init($url); ...
    HushuilongHushuilong
    Aug 5, 2011 at 7:18 am
    Aug 5, 2011 at 2:47 pm
  • Merging 2 images #!/usr/bin/php &lt;?php // wallace Lau kok poh < //Instantiate a new Gmagick object $imgMain = new Gmagick('Torso_F.tiff'); $imgBarcode = new Gmagick('barcode.jpeg'); //stamp the ...
    WallacelaukokpohWallacelaukokpoh
    Aug 4, 2011 at 6:20 am
    Aug 4, 2011 at 3:03 pm
  • There is a bug when around a month change. The bug url: https://bugs.php.net/bug.php?id=27793 To work around this ,check the method below : Pass the timestamp of the first second on the first day in ...
    HushuilongHushuilong
    Aug 31, 2011 at 9:33 am
    Dec 14, 2014 at 11:59 am
  • This comment apply to PHP5+ We can now do thing like this with strtotime: <?php $weekMondayTime = strtotime('Monday this week'); ? However this works based on a week starting Sunday. I do not know if ...
    MickoZMickoZ
    Aug 10, 2011 at 5:51 pm
    Dec 14, 2014 at 11:30 am
  • If you want to be interoperable with other PKCS #7 padding implementations, like the Legion of the Bouncy Castle Java cryptography APIs, you should always pad, that is a 8-byte (block size) padding ...
    Antonio Daeliminare BonifatiAntonio Daeliminare Bonifati
    Aug 1, 2011 at 12:54 pm
    Nov 9, 2013 at 11:17 am
  • Simple DES-ECB binary string encryption/decryption (no initialization vector). I implement PKCS7-padding the right way. This is better than Mcrypt default zero-padding. <?php function encrypt($str, ...
    Antonio Daeliminare BonifatiAntonio Daeliminare Bonifati
    Aug 1, 2011 at 10:20 am
    Nov 9, 2013 at 11:13 am
  • Start session only if not already started: <?php if (!isset ($_COOKIE[ini_get('session.name')])) { session_start(); } ? ---- Server IP: 69.147.83.197 Probable Submitter: 68.59.49.197 ---- Manual Page ...
    QuicktipsonQuicktipson
    Aug 14, 2011 at 4:29 am
    Oct 22, 2013 at 6:45 am
  • That is for example how getting filesize with bytes ending. <?php function FileSize($file, $setup = null) { $FZ = ($file && @is_file($file)) ? filesize($file) : NULL; $FS = ...
    Stachu540Stachu540
    Aug 30, 2011 at 3:58 pm
    Jan 22, 2013 at 12:18 am
  • A list containing the longitudes and latitudes of a number of major cities around the world as compiled from all previous notes on this page. // --- Asia --- // // Baku, Azerbaijan, Asia ...
    TularisTularis
    Aug 28, 2011 at 6:15 pm
    Nov 26, 2012 at 3:03 am
  • It's worth noting that authentication is not available in replicaSet with sharding before MongoDB version 1.9.1 http://www.mongodb.org/display/DOCS/Security+and+Authentication ---- Server IP: ...
    JuliusJulius
    Aug 4, 2011 at 10:30 am
    Sep 2, 2012 at 12:18 pm
  • There is no php_mongo.dll for x64 PHP. PHP doesn't load pre-compiled version (error: "%1 is not a valid Win32 application") ---- Server IP: 69.147.83.197 Probable Submitter: 93.182.135.152 ---- ...
    EnzoEnzo
    Aug 10, 2011 at 3:46 pm
    Sep 1, 2012 at 3:25 pm
  • I have found a simple way to test if a number is divisible by another. <?php for ($x=0; $x<14; $x++) { $num = $x/3; //if $x is NOT divisible, $num will be a float if (is_int($num)) { echo $x . ' is ...
    Milespickens+phpMilespickens+php
    Aug 23, 2011 at 9:56 pm
    Aug 2, 2012 at 3:08 pm
  • The scenario with adding SELECT SCOPE_IDENTITY after INSERT works. But in my a little bit complicated schema I got false when I called sqlsrv_fetch(.) I modified reading SCOPE_IDENTITY as: "Read the ...
    VavraVavra
    Aug 30, 2011 at 12:31 pm
    Jun 18, 2012 at 3:21 pm
  • PHP FILTER_VALIDATE_EMAIL validates with no TLD <?php var_dump(filter_var('bob@example', FILTER_VALIDATE_EMAIL)); ? Output bool(false) expected. But it returns: string(11) "bob@example" ---- Server ...
    SampathpereraSampathperera
    Aug 3, 2011 at 5:33 am
    May 9, 2012 at 2:22 pm
  • Correct Polish date: <?php function pldate($format='j F Y',$date=False){ $date = (is_numeric($date)?$date:time()); $m=array(1= 'styczeÅ„','luty','marzec','kwiecieÅ„','maj','czerwiec', ...
    Zryty Hekko PlZryty Hekko Pl
    Aug 6, 2011 at 6:42 am
    Feb 9, 2012 at 8:50 pm
  • Convert a week number to a date: <?php $year = 2011; $week_num_correction = strftime('%U', mktime(0,0,0,1,1,$year)) === '00' ? 1 : 0; for($week = 1; $week < 54; $week++) { $begin = strtotime("this ...
    ChrisChris
    Aug 19, 2011 at 3:38 pm
    Feb 9, 2012 at 8:50 pm
  • Simple but useful function to get academic year. <?php function academic_year() { $year=date(Y); if (date(n)<8) $year--; return $year; } ? ---- Server IP: 69.147.83.197 Probable Submitter: ...
    SeldimiSeldimi
    Aug 29, 2011 at 3:40 pm
    Feb 9, 2012 at 8:49 pm
  • I explained this to my newbies the difference though it would be good to demonstrate this here. If you are evaluating a list you cannot use strstr as it looks for any occurance. The correct way is ...
    Xydon1Xydon1
    Aug 31, 2011 at 9:59 pm
    Oct 27, 2011 at 6:34 pm
  • Here is very nifty function that returns a states fullname from it's 2 letter representation. <?php function returnState($ch2){ switch($ch2){ case "AL": $sT = "Alabama"; break; case "AZ": $sT = ...
    Glenn Dayton24Glenn Dayton24
    Aug 31, 2011 at 9:27 pm
    Oct 3, 2011 at 4:45 pm
  • strange differing Behaviour of array_merge and adding arrays with Superglobal $GLOBALS: $test_arr=array('test'= 'hallo'); //merge $test_arr into $GLOBALS (doesn't work) $GLOBALS=array_merge($GLOBALS, ...
    M HopfM Hopf
    Aug 31, 2011 at 11:35 pm
    Aug 31, 2011 at 11:51 pm
  • This is my solution if you are looking for a function that checks if the date is valid and also check if the date is in the future (for example passing only the month and year for a credit card ...
    FabrizioatbibivudotcomFabrizioatbibivudotcom
    Aug 31, 2011 at 3:53 pm
    Aug 31, 2011 at 3:54 pm
  • $tags = 'b|i|size|color|center|quote|url|img'; ...should be... $tags = 'b|i|size|color|center|quote|url|img|video'; ---- Server IP: 69.147.83.197 Probable Submitter: 212.159.66.96 ---- Manual Page -- ...
    BobBob
    Aug 31, 2011 at 2:47 pm
    Aug 31, 2011 at 2:53 pm
  • Hello Guys, Could anybody suggest a tutorial/Howto of PHP-OpenSSL programing please, thanks ---- Server IP: 69.147.83.197 Probable Submitter: 86.47.231.110 ---- Manual Page -- ...
    Simpleweb IeSimpleweb Ie
    Aug 31, 2011 at 2:46 pm
    Aug 31, 2011 at 2:47 pm
  • <?php #diego trindade #date demo $dateSrc = '2005-04-19 12:50 GMT'; $dateTime = date_create( $dateSrc);; # Now set a new date using date_format(); date_format( $dateTime, 2000, 12, 12); echo "New ...
    DiegobtrindadeDiegobtrindade
    Aug 31, 2011 at 2:27 pm
    Aug 31, 2011 at 2:28 pm
  • Ternary Operators is only to PHP 5.3, but you can do somethink similar on older versions. <?php // PHP 5.3 $data = 5; $data = $data ?: 10; // PHP 5.2 or lower $data = 5; !$data && $data = 10; ? Note ...
    DavidrodriguesDavidrodrigues
    Aug 31, 2011 at 4:01 am
    Aug 31, 2011 at 2:25 pm
  • Instead of dirname(__FILE__) use __DIR__ while using php 5.3 ---- Server IP: 69.147.83.197 Probable Submitter: 178.25.107.164 ---- Manual Page -- http://www.php.net/manual/en/function.dirname.php ...
    AnonymousAnonymous
    Aug 31, 2011 at 7:24 am
    Aug 31, 2011 at 2:03 pm
  • for a simple case insensitive compare you can use this (php = 5.3): $greetings = array('howdy', 'Hey', 'aloha he'); uasort($a, function($a, $b){ return strcasecmp($a, $b); }); //$a == array('aloha ...
    ClemClem
    Aug 31, 2011 at 11:53 am
    Aug 31, 2011 at 1:55 pm
  • Be aware of the Pedobear. He is lurking in this manual and he searches for new victims. Notice that if you help the FBI to catch the Pedobear you will be rewarded with a great amount of gold. ---- ...
    InfoInfo
    Aug 31, 2011 at 12:27 pm
    Aug 31, 2011 at 1:52 pm
  • How do you unserialized a disc on mac? ---- Server IP: 69.147.83.197 Probable Submitter: 24.251.22.104 ---- Manual Page -- http://www.php.net/manual/en/function.unserialize.php Edit -- ...
    Idamn KyleIdamn Kyle
    Aug 31, 2011 at 1:28 am
    Aug 31, 2011 at 2:35 am
  • Very CLEAR version of func., with example, and where to download fonts.... <?php function calculateTextBox($text,$fontFile,$fontSize,$fontAngle) { /************ simple function that calculates the ...
    JodybrabecJodybrabec
    Aug 30, 2011 at 10:35 pm
    Aug 31, 2011 at 12:10 am
  • highlight Search Words <? function highlight($word, $subject) { $split_subject = explode(" ", $subject); $split_word = explode(" ", $word); foreach ($split_subject as $k = $v){ foreach ($split_word ...
    Ayman2243Ayman2243
    Aug 30, 2011 at 11:50 pm
    Aug 31, 2011 at 12:08 am
  • Most of the time people iterate over a directory with 'opendir' or 'readdir' to add files to a zip. Like... while ($file = readdir($dir)) { ... $zip- addFile($file) } Note that $zip- addFile($file) ...
    YiiwanabYiiwanab
    Aug 30, 2011 at 5:15 pm
    Aug 30, 2011 at 5:40 pm
  • Bug. Sven Arduwie 23-Jun-2008 10:43 Code: if ('..' == $part) { array_pop($absolutes); //!bad ... var_dump(get_absolute_path('this/is/../a/./test/.///is')); Try this: ...
    Peter MlichPeter Mlich
    Aug 30, 2011 at 7:22 am
    Aug 30, 2011 at 5:13 pm
  • The performance decrease problem noted by Michal can be avoided by not handling E_NOTICE which in turn can be done by supplying E_ALL ^ E_NOTICE as the "error_types" parameter for this function, ...
    RanRan
    Aug 30, 2011 at 12:44 pm
    Aug 30, 2011 at 5:13 pm
  • you can print all the variables in $_SERVER using the following code. <?php print_r($_SERVER); ? The output is not going to be aligned but at least you will get you all the fields, that you want to ...
    Hak74attheplacecalledhotmailHak74attheplacecalledhotmail
    Aug 30, 2011 at 1:52 pm
    Aug 30, 2011 at 5:13 pm
  • note to (arnold at jasny dot net): try using <?php var_dump($foo == $bar- scalar); ? ---- Server IP: 69.147.83.197 Probable Submitter: 187.55.215.170 ---- Manual Page -- ...
    SparkSpark
    Aug 30, 2011 at 2:44 pm
    Aug 30, 2011 at 5:12 pm
  • This function has limited entrophy. So, if you want to create random string, it will produce only about 2 billion different strings, no matter the length of the string. This can be serous security ...
    Rok KraljRok Kralj
    Aug 30, 2011 at 4:08 pm
    Aug 30, 2011 at 5:12 pm
  • phpjs.org has a better version of strip_tags. I've taken their javascript and translated it to PHP: function my_strip_tags ($input, $allowed) { // Strips HTML and PHP tags from a string // // ...
    OldmanbimOldmanbim
    Aug 30, 2011 at 4:43 pm
    Aug 30, 2011 at 5:08 pm
  • Simple trick to current need: I want to get a function result in a variable or another value if it is empty. Instead of a long if then else structure like: $x = myFunction($y); if (empty($x)) x$ = ...
    ThierryhussonThierryhusson
    Aug 29, 2011 at 6:58 pm
    Aug 29, 2011 at 8:06 pm
Group Navigation
period‹ prev | Aug 2011 | next ›
Group Overview
groupphp-notes @
categoriesphp
discussions452
posts834
users382
websitephp.net

382 users for August 2011

Danbrown: 337 posts Anonymous: 28 posts Thiago: 17 posts Peter Cowburn: 15 posts Tularis: 13 posts : 8 posts Phpdoc: 4 posts Matthewkastor: 4 posts Daniel Rhodes: 4 posts Itworkarounds: 3 posts Serge: 3 posts Antonio Daeliminare Bonifati: 3 posts Itworkarounds: 3 posts Leahayes: 3 posts Daffy: 3 posts Friendlycode: 3 posts Wallacelaukokpoh: 3 posts Mez: 2 posts Chris: 2 posts Ivanspires: 2 posts
show more
Archives