note 95459 added to domnode.haschildnodes
This function is a bit tricky. If you want to find XML childnodes it is useless. You need to create a work-around:
<?php
$x = new DOMDocument();
$x->loadXML('
<A>
<B>b-text</B>
<C>
<D>d-text</D>
</C>
<E/>
</A>');
shownode($x->getElementsByTagName('A')->item(0));
function shownode($x) {
foreach ($x->childNodes as $p)
if (hasChild($p)) {
echo $p->nodeName.' -> CHILDNODES<br>';
shownode($p);
} elseif ($p->nodeType == XML_ELEMENT_NODE)
echo $p->nodeName.' '.$p->nodeValue.'<br>';
}
function hasChild($p) {
if ($p->hasChildNodes()) {
foreach ($p->chi
|
1/4/2010 1:53:44 PM
|
0
|
syngcwatsyncgw....@osu1.php.net
|
note 95458 added to function.readdir
this simple function will index the directories and sub-directories of a given dir
function get_dirs($dir){
global $dirs;
if (!isset($dirs)){$dirs = '';}
if(substr($dir,-1) !== '\\'){$dir .= '\\';}
if ($handle = opendir($dir)){
while (false !== ($file = readdir($handle))){
if (filetype($dir.$file) === 'dir' && $file != "." && $file != ".."){
clearstatcache();
$dirs .= $file . "\n";
get_dirs($dir . $file);
}
}
closedir($handle);
}
return $dirs;
}
----
Server IP: 69.147.83.197
Probable Submitter: 85.31.83.46 (proxied: 127.0.0.1)
----
Manual Pa
|
1/4/2010 1:36:41 PM
|
0
|
yasirla...@live.com
|
note 95445 added to function.dio-read
I am using dio functions on windows to read RS232 port.
I can read/write but it seems that the write function cannot be binary.
In particular:
dio_write($com1,chr(10),1); will result in writing 2 bytes 0D 0A be cause \n is translated to \r\n. I have not found any way to overcome this limitation so far
----
Server IP: 69.147.83.197
Probable Submitter: 210.64.15.56
----
Manual Page -- http://www.php.net/manual/en/function.dio-read.php
Edit -- https://master.php.net/note/edit/95445
Del: integrated -- https://master.php.net/note/delete/95445/integrated
Del: useless -- http
|
1/4/2010 2:14:22 AM
|
1
|
m...@mail.seven.com.tw
|
note 95444 added to function.rmdir
I don't think and of the recursive function here actually work so here is my one that does...
<?php
function rmrf($path){
$files = scandir($path);
foreach($files as $file){
if ($file !== '.' && $file !== '..'){
if(is_dir($path.'/'.$file)){
if (count(glob($path.'/'.$file.'/*')) > 0){
rmrf($path.'/'.$file);
}else{
rmdir($path.'/'.$file);
}
}else{
unlink($path.'/'.$file);
}
}
}
rmdir($path);
}
?>
----
Server IP: 87.124.86.46
Probable Submitter: 188.220.133.216 (proxied: 188.220.133.216)
----
Manual Page -
|
1/4/2010 1:36:18 AM
|
0
|
ja...@jacekk.co.uk
|
note 95443 added to book.array
taking from "PHP and MySQL Web Develpment"
<?php
@ $fp = fopen("../orders/orders.txt", 'r');
if (!orders)
{
echo '<p><strong>No orders pending. '
.'Please try again later.</strong></p>';
}
while (!feof($fp)
{
$order= fgets($fp, 999);
echo $orders . '</ br>';
}
fclose($fp);
?>
----
Server IP: 89.185.144.38
Probable Submitter: 86.41.106.207
----
Manual Page -- http://www.php.net/manual/en/book.array.php
Edit -- https://master.php.net/note/edit/95443
Del: integrated -- https://master.php.net/note/delete/95443/integrated
|
1/3/2010 11:29:20 PM
|
1
|
Fergal...@osu1.php.net
|
note 95442 added to function.ssh2-sftp-mkdir
I am having trouble removing folders using SSH2 because permissions are being set to 0775 even when I set them to 0777 using this function. The remove directory function only seems to work on folders with 0777 permissions.
----
Server IP: 69.147.83.197
Probable Submitter: 86.53.80.168
----
Manual Page -- http://www.php.net/manual/en/function.ssh2-sftp-mkdir.php
Edit -- https://master.php.net/note/edit/95442
Del: integrated -- https://master.php.net/note/delete/95442/integrated
Del: useless -- https://master.php.net/note/delete/95442/useless
Del: bad code -- https://mast
|
1/3/2010 10:54:12 PM
|
1
|
op...@osu1.php.net
|
note 95441 added to pdostatement.fetchobject
Its worth noting that the settings are done before the call to the constructor:
class NewsVO
{
var $id;
var $title;
var $content;
var $date;
public function __construct()
{
die($this->title);
}
}
Print the title instead of nothing! I am not sure its a bug, because its very usefull to do some post-treatment on the VO properties...
So, question is, can we use it as a special PDO feature or its a pure bug?
----
Server IP: 69.147.83.197
Probable Submitter: 93.1.160.222
----
Manual Page -- http://www.php.net/manual/en/pdostatement.fetchobject.php
Edi
|
1/3/2010 9:23:27 PM
|
1
|
thomasdec...@ebuildy.com
|
note 95440 added to function.array-walk
A little note.
Previous example works only in PHP 5.3 and greater.
----
Server IP: 93.93.89.253
Probable Submitter: 194.220.83.177
----
Manual Page -- http://www.php.net/manual/en/function.array-walk.php
Edit -- https://master.php.net/note/edit/95440
Del: integrated -- https://master.php.net/note/delete/95440/integrated
Del: useless -- https://master.php.net/note/delete/95440/useless
Del: bad code -- https://master.php.net/note/delete/95440/bad+code
Del: spam -- https://master.php.net/note/delete/95440/spam
Del: non-english -- https://master.php.net/note/delet
|
1/3/2010 4:59:21 PM
|
1
|
Anonym...@osu1.php.net
|
note 95439 added to install.windows.iis
If you encounter the following error using PHP under IIS: "Warning: session_start(): open .... failed", you need to grant "read/write" permissions to the "IUSR" on the directory listed in "session.save_path" (in "php.ini").
In Vista, do the following:
1. Right-click on folder defined in "session.save_path" in "php.ini" file. (ex: "C:\Windows\Temp")
2. Select "Properties"
3. Click "Security" tab
4. Click "Edit"
5. Click "Add"
6. Click "Advanced"
7. Click "Find Now"
8. Select "IUSR"
9. Click "OK"
10. Click "OK".
11. Under "Permissions for IUSR", ensure the following are checked:
|
1/3/2010 4:41:13 PM
|
0
|
...@osu1.php.net
|
note 95438 added to function.explode
kurze frage,
z.B.:
$string[1]=explode($string[1],";");
wie wird der string dann abgespeichert
($string[1][0] oda so??)
----
Server IP: 69.147.83.197
Probable Submitter: 91.206.225.139
----
Manual Page -- http://www.php.net/manual/en/function.explode.php
Edit -- https://master.php.net/note/edit/95438
Del: integrated -- https://master.php.net/note/delete/95438/integrated
Del: useless -- https://master.php.net/note/delete/95438/useless
Del: bad code -- https://master.php.net/note/delete/95438/bad+code
Del: spam -- https://master.php.net/note/delete/95438
|
1/3/2010 4:35:23 PM
|
1
|
...@osu1.php.net
|
note 95437 added to function.array-walk
You can use lambda function as a second parameter:
<?php
array_walk($myArray, function(&$value, $key){
// if you want to change array values then "&" before the $value is mandatory.
});
?>
Example (multiply positive values by two):
<?php
$myArray = array(1, 2, 3, 4, 5);
array_walk($myArray, function(&$value, $index){
if ($value > 0) $value *= 2;
});
?>
----
Server IP: 93.93.89.253
Probable Submitter: 194.220.83.177
----
Manual Page -- http://www.php.net/manual/en/function.array-walk.php
Edit -- https://master.php.net/note/edit/95437
Del: integrated --
|
1/3/2010 3:17:15 PM
|
0
|
arekand...@yandex.ru
|
note 95436 added to function.trim
Noticed strange behavior when trimming a directory off a file name starting with the letter "o".
<?php
$filePath = 'blog/2010/oh-this-is-an-example';
$section = 'blog/2010';
echo ltrim($filePath, $section);
?>
result: h-this-is-an-example
Does anyone know what "/o" is and why this is stripped?
Current fix:
<?php
$filePath = 'blog/2010/oh-this-is-an-example';
$filePath = str_replace('/o', '/O', $filePath); //FIX for filenames beginning with "o"
$section = 'blog/2010';
echo ltrim($filePath, $section);
?>
result: Oh-this-is-an-example
----
Server IP: 92.48.74.199
|
1/3/2010 3:06:17 PM
|
1
|
mash...@toshine.net
|
note 95435 added to function.method-exists
Hi,
Your first argument is not an optional one. You should place it at the end.
----
Server IP: 69.147.83.197
Probable Submitter: 81.57.139.130
----
Manual Page -- http://www.php.net/manual/en/function.method-exists.php
Edit -- https://master.php.net/note/edit/95435
Del: integrated -- https://master.php.net/note/delete/95435/integrated
Del: useless -- https://master.php.net/note/delete/95435/useless
Del: bad code -- https://master.php.net/note/delete/95435/bad+code
Del: spam -- https://master.php.net/note/delete/95435/spam
Del: non-english -- https://master.
|
1/3/2010 1:44:19 PM
|
1
|
miaseyeATgmailDOT...@osu1.php.net
|
note 95434 added to tutorial.firstpage
If you save your code as UTF-8, make sure that the BOM (EF BB BF) is not present as the first 3 bytes of the file otherwise it may interfere with the code if the PHP need to be run before any output (e.g. header()).
----
Server IP: 69.147.83.197
Probable Submitter: 119.247.149.171
----
Manual Page -- http://www.php.net/manual/en/tutorial.firstpage.php
Edit -- https://master.php.net/note/edit/95434
Del: integrated -- https://master.php.net/note/delete/95434/integrated
Del: useless -- https://master.php.net/note/delete/95434/useless
Del: bad code -- https://master.php.net
|
1/3/2010 1:43:17 PM
|
0
|
mikl...@gmail.com
|
note 95433 added to language.exceptions
If you are using exceptions, code which will store uncaught exceptions might be nice for you,
for example,
PDO throws an exception, but you thought that this is impossible, so you were not even thinking about using try{...}catch(...){...},
function exception_handler($exception) {
ob_start();
print_r($GLOBALS);
print_r($exception);
file_put_contents('exceptions.txt', ob_get_clean(). "\n",FILE_APPEND);
}
set_exception_handler('exception_handler');
to save a uncatched exception simply write
throw new Exception('error');
somewhere in code.
If we have a lot of exceptions, f
|
1/3/2010 12:43:20 PM
|
0
|
test30...@gmail.com
|
note 95432 added to features.file-upload.post-method
To Michael.
Have you tried it with "/home/username/public_html/uploaddir" ? i mean, by preceding the path with the root /.
Otherwise, "home/username/public_html/uploaddir" is the same as "./home/username/public_html/uploaddir".
Sorry for the inconveniences, but asking is free!
----
Server IP: 69.147.83.197
Probable Submitter: 84.124.216.190
----
Manual Page -- http://www.php.net/manual/en/features.file-upload.post-method.php
Edit -- https://master.php.net/note/edit/95432
Del: integrated -- https://master.php.net/note/delete/95432/integrated
Del: useless -- https://
|
1/3/2010 9:54:16 AM
|
1
|
chic...@osu1.php.net
|
note 95431 added to function.imagick-coalesceimages
Where an example of use of this function. On one site has not found a way of application...
----
Server IP: 195.54.192.44
Probable Submitter: 94.180.131.201
----
Manual Page -- http://www.php.net/manual/en/function.imagick-coalesceimages.php
Edit -- https://master.php.net/note/edit/95431
Del: integrated -- https://master.php.net/note/delete/95431/integrated
Del: useless -- https://master.php.net/note/delete/95431/useless
Del: bad code -- https://master.php.net/note/delete/95431/bad+code
Del: spam -- https://master.php.net/note/delete/95431/spam
Del: non-english
|
1/3/2010 9:42:13 AM
|
1
|
it_is_g...@mail.ru
|
note 95430 added to function.preg-quote
preg_quote wasn't escaping the hyphen. According to a previous comment, this is a bug that has been fixed as of 5.3. Here is a function that fixes it:
<?php
function regex_quote ($str, $delim='/')
{
$quoted = preg_quote($str, $delim);
if ( version_compare(PHP_VERSION, '5.3.0', '<') )
$quoted = str_replace('-', '\\-', $quoted);
return $quoted;
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 71.238.254.92
----
Manual Page -- http://www.php.net/manual/en/function.preg-quote.php
Edit -- https://master.php.net/note/edit/95430
Del: integrated -- https://mas
|
1/3/2010 4:35:18 AM
|
0
|
corydotmawhorteratephectivedot...@osu1.php.net
|
note 95429 added to reserved.variables.globals
#!/usr/bin/php
<?php
unset($GLOBALS);
$GLOBALS['variable1'] = "string1";
$GLOBALS['variable2'] = "string2";
$GLOBALS['variable3'] = "string3";
$GLOBALS['variable4'] = "string4";
function testFunc () {
foreach (array_keys($GLOBALS) as $globy) {
$$globy = $GLOBALS[$globy];
}
echo <<<_END_
$variable1
$variable2
$variable3
$variable4
_END_;
}
echo testFunc();
?>
----
Server IP: 69.147.83.197
Probable Submitter: 24.94.245.84
----
Manual Page -- http://www.php.net/manual/en/reserved.variables.globals.php
Edit -- https://master.php.net/n
|
1/3/2010 2:07:24 AM
|
1
|
casey.hyperspire....@osu1.php.net ((at) (dot))
|
note 95428 added to function.sprintf
The explanation on this page is incorrect
Examples 3 and 4 are false
%1$s is not valid, the correct syntax is %1\$s
Examples corrected
Example #3 Argument swapping
<?php
$format = 'The %2\$s contains %1\$d monkeys';
printf($format, $num, $location);
?>
Example #4 Argument swapping
<?php
$format = 'The %\2$s contains %1\$d monkeys.
That\'s a nice %2\$s full of %1\$d monkeys.';
printf($format, $num, $location);
?>
----
Server IP: 217.71.118.186
Probable Submitter: 213.219.182.218
----
Manual Page -- http://www.php.net/manual/en/function.sprintf.php
Edit
|
1/3/2010 1:14:14 AM
|
1
|
Anonym...@osu1.php.net
|
note 95427 added to function.sprintf
L'explication sur cette page est incorrecte
les exemples 3 et 4 sont faux
%1$s n'est pas valide, la syntaxe correcte est %1\$
Exemples corrigés
Example #3 Argument swapping
<?php
$format = 'The %2\$s contains %1\$d monkeys';
printf($format, $num, $location);
?>
Example #4 Argument swapping
<?php
$format = 'The %\2$s contains %1\$d monkeys.
That\'s a nice %2\$s full of %1\$d monkeys.';
printf($format, $num, $location);
?>
----
Server IP: 217.71.118.186
Probable Submitter: 213.219.182.218
----
Manual Page -- http://www.php.net/manual/en/function.sprintf.php
|
1/3/2010 1:12:26 AM
|
1
|
Anonym...@osu1.php.net
|
note 95426 added to function.sprintf
L'explication sur cette page est incorrecte
les exemple 3 et 4 sont faux
%1$s n'est pas valide, la syntaxe correcte est %1\$
Exemples corrigés
Example #3 Argument swapping
<?php
$format = 'The %2\$s contains %1\$d monkeys';
printf($format, $num, $location);
?>
Example #4 Argument swapping
<?php
$format = 'The %\2$s contains %1\$d monkeys.
That\'s a nice %2\$s full of %1\$d monkeys.';
printf($format, $num, $location);
?>
----
Server IP: 217.71.118.186
Probable Submitter: 213.219.182.218
----
Manual Page -- http://www.php.net/manual/en/function.sprintf.php
|
1/3/2010 1:11:23 AM
|
1
|
Anonym...@osu1.php.net
|
note 95425 added to function.feof
Please note that feof() used with TCP-Connections, returns false as long as the connection is open.
It even returns false when there is no data available.
BTW: Using feof() with HTTP for a single request, you should always make sure that you set the HTTP-Header "Connection" to "close" and _not_ to "keep-alive".
----
Server IP: 212.124.37.9
Probable Submitter: 88.76.119.128
----
Manual Page -- http://www.php.net/manual/en/function.feof.php
Edit -- https://master.php.net/note/edit/95425
Del: integrated -- https://master.php.net/note/delete/95425/integrated
Del: useless --
|
1/3/2010 12:45:15 AM
|
0
|
jakic...@osu1.php.net
|
note 95424 added to function.printer-open
HOW TO KICK CASHDRAWER OPEN
AFTER PRINTING .....
HELP OR SUGGEST ME PLEASE
THIS IS MY CODE FOR PRINTER 's COMMAND
if($all_info)
{
$lines = "";
$lines = explode("\r\n",$all_info);
$a="0";
$handle = printer_open("TMU-950 CUT");
printer_start_doc($handle, $orderno); printer_start_page($handle);
$font = printer_create_font($printer_font, 11, 11, 0, false, false, false, 0);
printer_select_font($handle, $font);
for($i=0; $i<count($lines); $i++)
{
printer_draw_text($handle, $lines[$i], 0, $a,5);
$a+=$line_height;
}
printer_delete_font($font); printer
|
1/2/2010 9:57:21 PM
|
1
|
sakd...@hotmail.com
|
note 95423 added to function.addslashes
<?php
// I wrote this function because I wanted to apply addslashes
// no earlier than at the query string, but I didn't want to
// have to escape each variable separately. Note that the
// query string must be enclosed in single quotes, to prevent
// the variables from being interpreted before they get passed
// to the function.
//
// The function will detect variables of the following forms:
// $variable
// $variable[0]
// $variable[string]
function escaped($query, $function = "addslashes") {
$e = preg_replace("|\\\$([a-zA-Z_][a-zA-Z0-9_]+)\[([^\]]*?)\]|e", "$function(
|
1/2/2010 9:50:32 PM
|
1
|
phpdotnet-sh...@pressbin.com
|
note 95422 added to function.mail
RFC-2822 is quite explicit, that "Though some message systems locally store messages in this format (which eliminates the need for translation between formats) and others use formats that differ from the one specified in this standard, local storage is outside of the scope of this standard."
And it is not just "some", but most Unix mailers choke when you try pipe CRLF instead of Unix line endings to "sendmail" command. PHP is using line endings as is, so you have better chances for success if you use Unix file format or line endings.
----
Server IP: 69.147.83.197
Probable Submitter: 6
|
1/2/2010 9:46:16 PM
|
0
|
rch+...@online.lt
|
note 95421 added to function.fgetcsv
I was free to modifie the class from jaimthorn
http://www.php.net/manual/de/function.fgetcsv.php#88616
My problem was/is that i´ve got many line breaks in my spreadsheet fields.
As result of this i had many line breaks in my csv-file, witch let php thinks, that it is a new coloum/line in the spreadsheet -> Epic Fail ! =)
So i modified the class a little
bit and maybe some one need it also like me.
Sry for my bad english.
Here it goes, only the changes you´ve to change
<?php
....
class PaperPear_CSVParser
{
....
private $header_index = '';
private $current_r
|
1/2/2010 9:23:49 PM
|
1
|
MarcoMosc...@osu1.php.net
|
note 95420 added to function.rand
Another way to create an array of random numbers where there are no identical numbers.
($n = number of random numbers to return in the array
$min = minimum number
$max = maximum number)
<?php
function uniqueRand($n, $min = 0, $max = null)
{
if($max === null)
$max = getrandmax();
$array = range($min, $max);
$return = array();
$keys = array_rand($array, $n);
foreach($keys as $key)
$return[] = $array[$key];
return $return;
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 72.208.240.199
----
Manual Page -- http://www.php.net/manual/en/function.ra
|
1/2/2010 7:11:25 PM
|
0
|
JohnG...@osu1.php.net
|
note 95419 added to function.array-intersect
Actually array_intersect finds the dublicate values, here is my approach which is 5 times faster than built-in function array_intersect().. Give a try..
function my_array_intersect($a,$b)
{
for($i=0;$i<sizeof($a);$i++)
{
$m[]=$a[$i];
}
for($i=0;$i<sizeof($a);$i++)
{
$m[]=$b[$i];
}
sort($m);
$get=array();
for($i=0;$i<sizeof($m);$i++)
{
if($m[$i]==$m[$i+1])
$get[]=$m[$i];
}
return $get;
}
Barış ÇUHADAR
189780@gmai
|
1/2/2010 3:13:16 PM
|
0
|
189...@gmail.com
|
note 95418 added to mongocollection.remove
To remove a document based on its ID, you need to ensure that you pass the ID as a MongoID object rather than just a string:
<?php
$id = '4b3f272c8ead0eb19d000000';
// will not work:
$collection->remove(array('_id' => $id), true);
// will work:
$collection->remove(array('_id' => new MongoId($id)), true);
?>
----
Server IP: 69.147.83.197
Probable Submitter: 78.149.181.66
----
Manual Page -- http://www.php.net/manual/en/mongocollection.remove.php
Edit -- https://master.php.net/note/edit/95418
Del: integrated -- https://master.php.net/note/delete/95418/integrated
Del:
|
1/2/2010 1:42:23 PM
|
0
|
DavidWin...@osu1.php.net
|
note 95417 added to function.stream-socket-server
I had a horrible time trying to shove a TLS socket into an existing TCP program. It appears to me that functions like stream_socket_recvfrom and stream_socket_sendto don't work with TLS/SSL (which may be obvious to PHP gurus...sorry if it is, I'm in a bit over my head here).
In the end I ended up doing all my IO with fread() and fwrite(), which solved all my problems.
----
Server IP: 69.147.83.197
Probable Submitter: 76.179.160.225
----
Manual Page -- http://www.php.net/manual/en/function.stream-socket-server.php
Edit -- https://master.php.net/note/edit/95417
Del: integrated
|
1/2/2010 11:34:24 AM
|
0
|
pete...@me.com
|
note 95416 added to function.func-get-arg
A much more efficient way then the example shown by beta3designs [at] gmail [dot] com
<?php
function avg(){
return array_sum(func_get_args()) / func_num_args();
}
echo sprintf("%.2f", avg(2,1,2,1,3,4,5,1,3,6));
?>
----
Server IP: 212.124.37.9
Probable Submitter: 87.79.61.219
----
Manual Page -- http://www.php.net/manual/en/function.func-get-arg.php
Edit -- https://master.php.net/note/edit/95416
Del: integrated -- https://master.php.net/note/delete/95416/integrated
Del: useless -- https://master.php.net/note/delete/95416/useless
Del: bad code -- https://maste
|
1/2/2010 4:11:15 AM
|
1
|
jackfoxm...@gmail.com
|
note 95415 added to class.errorexception
As noted below, it's important to realize that unless caught, any Exception thrown will halt the script. So converting EVERY notice, warning, or error to an ErrorException will halt your script when something harmlesss like E_USER_NOTICE is triggered.
It seems to me the best use of the ErrorException class is something like this:
<?php
function custom_error_handler($number, $string, $file, $line, $context)
{
// Determine if this error is one of the enabled ones in php config (php.ini, .htaccess, etc)
$error_is_enabled = (bool)($number & ini_get('error_reporting') );
// -- FA
|
1/2/2010 4:03:24 AM
|
0
|
triplepo...@gmail.com
|
note 95414 added to function.shuffle
Here is a quick function I wrote that generates a random password and uses shuffle() to easily shuffle the order.
public function randPass($upper = 3, $lower = 3, $numeric = 3, $other = 2) {
//we need these vars to create a password string
$passOrder = Array();
$passWord = '';
//generate the contents of the password
for ($i = 0; $i < $upper; $i++) {
$passOrder[] = chr(rand(65, 90));
}
for ($i = 0; $i < $lower; $i++) {
$passOrder[] = chr(rand(97, 122));
}
for ($i = 0; $i < $numeric; $i++) {
$passOrder[] = chr(rand(48,
|
1/2/2010 2:46:21 AM
|
1
|
ty...@CompLangs.com
|
note 95413 added to function.fread
Note that fread() returns an empty string if you try to read beyond EOF, while the manual states otherwise ("Returns [...] FALSE on failure."). This e. g. happens with empty files (0 bytes long).
This does not look like a bug in PHP's fread() implementation to me, but rather like a documentation bug. The manpage for the C function fread() states:
> fread() does not distinguish between end-of-file and error, and callers must use feof(3) and ferror(3) to determine which occurred.
It also says:
> If an error occurs, or the end-of-file is reached, the return value is a short item count (or z
|
1/2/2010 1:16:20 AM
|
0
|
Tb...@osu1.php.net
|
note 95412 added to function.strtr
For the multibyte function (mb_strtr) I use the mbfunctions library:
http://code.google.com/p/mbfunctions/
It has the function mb_strip_accents also.
----
Server IP: 80.64.47.13
Probable Submitter: 95.214.45.176
----
Manual Page -- http://www.php.net/manual/en/function.strtr.php
Edit -- https://master.php.net/note/edit/95412
Del: integrated -- https://master.php.net/note/delete/95412/integrated
Del: useless -- https://master.php.net/note/delete/95412/useless
Del: bad code -- https://master.php.net/note/delete/95412/bad+code
Del: spam -- https://master.php.
|
1/1/2010 11:16:20 PM
|
1
|
...@osu1.php.net
|
note 95411 added to function.trim
If you need the multibyte function (mb_trim) check out the mbfunctions library:
http://code.google.com/p/mbfunctions/
----
Server IP: 80.64.47.13
Probable Submitter: 95.214.45.176
----
Manual Page -- http://www.php.net/manual/en/function.trim.php
Edit -- https://master.php.net/note/edit/95411
Del: integrated -- https://master.php.net/note/delete/95411/integrated
Del: useless -- https://master.php.net/note/delete/95411/useless
Del: bad code -- https://master.php.net/note/delete/95411/bad+code
Del: spam -- https://master.php.net/note/delete/95411/spam
Del: non
|
1/1/2010 11:13:21 PM
|
1
|
...@osu1.php.net
|
note 95410 added to function.array-values
Simple array_flatten that actually works...
takes a multi-dimensional array, and flattens into a zero indexed array.
function array_flatten($array, $flat = false)
{
if (!is_array($array) || empty($array)) return '';
if (empty($flat)) $flat = array();
foreach ($array as $key => $val) {
if (is_array($val)) $flat = array_flatten($val, $flat);
else $flat[] = $val;
}
return $flat;
}
----
Server IP: 69.147.83.197
Probable Submitter: 97.117.123.20
----
Manual Page -- http://www.php.net/manual/en/function.array-values.php
Edit --
|
1/1/2010 10:31:16 PM
|
1
|
cmat
|
note 95409 added to mysqli.installation
how to install it in VPS server running CentOS
i add
--with-mysqli=/usr/lib/mysql
and restart apache but it didnot work ??
any help
----
Server IP: 69.147.83.197
Probable Submitter: 41.232.98.77
----
Manual Page -- http://www.php.net/manual/en/mysqli.installation.php
Edit -- https://master.php.net/note/edit/95409
Del: integrated -- https://master.php.net/note/delete/95409/integrated
Del: useless -- https://master.php.net/note/delete/95409/useless
Del: bad code -- https://master.php.net/note/delete/95409/bad+code
Del: spam -- https://master.php.net/note/de
|
1/1/2010 10:01:24 PM
|
1
|
A7...@osu1.php.net
|
note 95408 added to function.pg-query-params
pg_query and pg_query_params can be combined into a single function. This also removes the need to construct a parameter array for pg_query_params:
function my_query($conn, $query)
{
if(func_num_args() == 2)
return pg_query($conn, $query);
$args = func_get_args();
$params = array_splice($args, 2);
return pg_query_params($conn, $query, $params);
}
Usage:
/* non-parameterized example */
my_query($conn, "SELECT $val1 + $val2");
/* parameterized example */
my_query($conn, "SELECT $1 + $2", $val1, $val2);
----
Server IP: 69.147.83.197
Probable Submitter: 75.14
|
1/1/2010 6:32:25 PM
|
1
|
...@esilo.com
|
note 95407 added to function.mail
hello frends
my question is this
header or function that I owe to add to this code or if someone can put the code and added the function and even better is that functional
when it comes sending gmail yahoo etc.
but hotmail does not reach
This is the code
<link rel="stylesheet" type="text/css" href="style.css">
<meta http-equiv="Content-Language" content="es">
<form method="POST" action="anonimo.php">
<p align="center">
Tu eMail:
<input type="text" name="email" size="20"><br>
Tu nombre:
<input type="text" name="nombre" size="20"><br>
Para (eMail):
|
1/1/2010 3:37:11 PM
|
1
|
darkmas...@osu1.php.net
|
note 95406 added to ref.fileinfo
For opensuse, you will just need to install the file-devel to solve the Problem with
checking for magic files in default path... not found
configure: error: Please reinstall the libmagic distribution
zypper install file-devel
----
Server IP: 74.208.171.221
Probable Submitter: 212.254.166.56
----
Manual Page -- http://www.php.net/manual/en/ref.fileinfo.php
Edit -- https://master.php.net/note/edit/95406
Del: integrated -- https://master.php.net/note/delete/95406/integrated
Del: useless -- https://master.php.net/note/delete/95406/useless
Del: bad code -- https://maste
|
1/1/2010 12:13:21 PM
|
0
|
ne...@nessi.ch
|
note 95405 added to function.getcwd
It might be more expedient to use explode if you want
to preserve the (e.g.) 2nd-to-last folder name before
the function output loads. In that case, initialize an
array and save the desired folder name from the get-go:
$namedir = array(); //initialize
$pathname = getcwd() ; // path named in main script
$newpath = str_replace('\\','/',$pathname,$count) ;
$namedir = explode("/",$newpath) ; //parse subfolders
$foldername = $namedir[count($namedir)-2] ; //2nd-to-last folder
Depending on your system, it may be possible to use dirname instead of $pathname=getcwd() but if you
want t
|
1/1/2010 11:05:19 AM
|
1
|
george.woo...@gmail.com
|
note 95404 added to language.oop5.abstract
Here's an example that helped me with understanding abstract classes. It's just a very simple way of explaining it (in my opinion). Lets say we have the following code:
<?php
class Fruit {
private $color;
public function eat() {
//chew
}
public function setColor($c) {
$this->color = $c;
}
}
class Apple extends Fruit {
public function eat() {
//chew until core
}
}
class Orange extends Fruit {
public function eat() {
//peel
//chew
}
}
?>
Now I give you an apple and you eat it.
|
1/1/2010 7:46:19 AM
|
0
|
mbajo...@gmail.com
|
note 95403 added to language.exceptions.extending
As previously noted exception linking was recently added (and what a god-send it is, it certainly makes layer abstraction (and, by association, exception tracking) easier).
Since <5.3 was lacking this useful feature I took some initiative and creating a custom exception class that all of my exceptions inherit from:
<?php
class SystemException extends Exception
{
private $previous;
public function __construct($message, $code = 0, Exception $previous = null)
{
parent::__construct($message, $code);
if (!is_null($previous))
{
$this -> previous = $previous;
}
|
12/31/2009 11:04:14 PM
|
0
|
iamhiddensomewh...@gmail.com
|
note 95402 added to function.strpos
The declaration is wrong. The return type should be "mixed" because of integer/boolean mix.
----
Server IP: 212.124.37.9
Probable Submitter: 93.212.112.112
----
Manual Page -- http://www.php.net/manual/en/function.strpos.php
Edit -- https://master.php.net/note/edit/95402
Del: integrated -- https://master.php.net/note/delete/95402/integrated
Del: useless -- https://master.php.net/note/delete/95402/useless
Del: bad code -- https://master.php.net/note/delete/95402/bad+code
Del: spam -- https://master.php.net/note/delete/95402/spam
Del: non-english -- https://maste
|
12/31/2009 8:02:06 PM
|
1
|
zuha...@thomaswacker.de
|
note 95401 added to language.oop5.overloading
http://php.net/manual/en/language.oop5.overloading.php#93890
incorrect as for php 5.3.1 & 5.2.12
You can check this by yourself:
<?php
class CSample {
public function __set($name, $value) {
$this->$name = $value;
print_r('__set() called');
}
}
$a = new CSample();
$c = $a->item = $a->b = 2;
var_dump($c, $a->item, $a->b);
?>
----
Server IP: 88.81.245.102 (proxied: 91.196.196.205 1.0 localhost.ua.elro.com:3128 (squid/2.7.STABLE7))
Probable Submitter: 95.132.62.25
----
Manual Page -- http://www.php.net/manual/en/language.oop5.overloading.php
Edit
|
12/31/2009 7:37:14 PM
|
1
|
fert...@list.ru
|
note 95400 added to internals2.objects
You should have used the superglobal $_REQUEST instead of $_GET & $_POST.
----
Server IP: 69.147.83.197
Probable Submitter: 80.94.101.83
----
Manual Page -- http://www.php.net/manual/en/internals2.objects.php
Edit -- https://master.php.net/note/edit/95400
Del: integrated -- https://master.php.net/note/delete/95400/integrated
Del: useless -- https://master.php.net/note/delete/95400/useless
Del: bad code -- https://master.php.net/note/delete/95400/bad+code
Del: spam -- https://master.php.net/note/delete/95400/spam
Del: non-english -- https://master.php.net/note/d
|
12/31/2009 12:22:13 PM
|
1
|
tcherno...@gmail.com
|
note 95399 added to function.ob-clean
If you are having problems setting headers, headers_sent() will tell you if and where headers were sent!
It helped me solve a difficult problem with serving a download file.
<?php
if (headers_sent($filename, $linenum)) {
echo "Headers already sent in $filename on line $linenum\n";
exit;
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 71.159.140.22
----
Manual Page -- http://www.php.net/manual/en/function.ob-clean.php
Edit -- https://master.php.net/note/edit/95399
Del: integrated -- https://master.php.net/note/delete/95399/integrated
Del: useless --
|
12/31/2009 7:46:07 AM
|
1
|
david.garli...@gmail.com
|
note 95398 added to function.fclose
In response to what sineld at sineld dot com wrote, you don't have to close the file to be able to read what you've written. You can call fflush() to flush the output buffer to the disk, fseek() to where you need to be, and fread() anything you wrote. Just make sure the mode you use with fopen() allows for anything you need to do with the file stream.
----
Server IP: 192.41.40.227
Probable Submitter: 70.47.131.176
----
Manual Page -- http://www.php.net/manual/en/function.fclose.php
Edit -- https://master.php.net/note/edit/95398
Del: integrated -- https://master.php.net/note/dele
|
12/31/2009 5:39:14 AM
|
1
|
...@pehjota.com
|
note 95397 added to function.is-numeric
I was looking for a way to see check to see if a variable is just a simple positive rational number without exponential notation or a sign. This is what I came up with.
if (is_numeric($input)){
if (is_int((int)$input))
$isNumber = true;
else
$isNumber = false;
}
else{
$isNumber = false;
}
----
Server IP: 69.147.83.197
Probable Submitter: 128.187.0.164
----
Manual Page -- http://www.php.net/manual/en/function.is-numeric.php
Edit -- https://master.php.net/note/edit/95397
Del: integrated -- https://master.php.net/note/delete/95397/integrated
Del: useless --
|
12/31/2009 5:21:06 AM
|
1
|
jotun....@gmail.com
|
note 95396 added to function.mail
Greetings from HerniHost,
The code above (written by Victor Benincasa), posted by Alex M., is a good and very simple way to prevent header injection, but I would like to suggest a little variation.
Because the function "eregi" is going to be deprecated on PHP 6, I suggest use the function "stristr", which in this case can be use to do the same function.
Note: In the function "stristr", parameters are in different order.
"stristr" example => stristr($value, "FROM:");
"eregi" example => eregi("FROM:", $value);
Full example using Victor Benincasa's code, but using my own code format
|
12/31/2009 5:19:06 AM
|
1
|
HernifromHerniHost....@osu1.php.net
|
note 95395 added to install.windows.iis
It's true, IIS web site has a utility to install php on your PC.
www.php.iis.net
----
Server IP: 69.147.83.197
Probable Submitter: 190.40.26.175
----
Manual Page -- http://www.php.net/manual/en/install.windows.iis.php
Edit -- https://master.php.net/note/edit/95395
Del: integrated -- https://master.php.net/note/delete/95395/integrated
Del: useless -- https://master.php.net/note/delete/95395/useless
Del: bad code -- https://master.php.net/note/delete/95395/bad+code
Del: spam -- https://master.php.net/note/delete/95395/spam
Del: non-english -- https://master.p
|
12/31/2009 4:19:05 AM
|
1
|
o...@osu1.php.net
|
note 95394 added to ref.var
that function of yours could be shortened by a couple lines;
<?
function ReduceVar ($Value) {
switch (gettype($Value)) {
case "boolean":
case "integer":
case "double":
case "string":
case "NULL":
return $Value;
case "resource":
return get_resource_type($Value);
case "object":
return ReduceVar(get_object_vars($Value));
case "array":
if (count($Value) > 0)
return ReduceVar(reset($Value));
default:
return NULL;
}
}
?>
|
12/31/2009 4:18:08 AM
|
1
|
distantimag...@gmail.com
|
note 95393 added to function.ziparchive-addemptydir
$this->zip->addEmptyDir($zip_path); may create empty file as the directory name and cause problem. Remark it and the problem will be resolved.
----
Server IP: 69.147.83.197
Probable Submitter: 210.3.38.210
----
Manual Page -- http://www.php.net/manual/en/function.ziparchive-addemptydir.php
Edit -- https://master.php.net/note/edit/95393
Del: integrated -- https://master.php.net/note/delete/95393/integrated
Del: useless -- https://master.php.net/note/delete/95393/useless
Del: bad code -- https://master.php.net/note/delete/95393/bad+code
Del: spam -- https://master
|
12/31/2009 4:16:12 AM
|
1
|
MICHAELW...@osu1.php.net
|
note 95392 added to function.class-implements
You can also check if a class implements an interface using instanceof.
E.g.
<?php
if($myObj instanceof MyInterface) {
echo "It is! It is!";
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 58.105.242.127
----
Manual Page -- http://www.php.net/manual/en/function.class-implements.php
Edit -- https://master.php.net/note/edit/95392
Del: integrated -- https://master.php.net/note/delete/95392/integrated
Del: useless -- https://master.php.net/note/delete/95392/useless
Del: bad code -- https://master.php.net/note/delete/95392/bad+code
Del: spam -- htt
|
12/31/2009 1:22:07 AM
|
0
|
p...@paulferrett.com
|
note 95391 added to mail.configuration
why not include an example that shows how to set this up in pop3 and or imap mail on gmail or something? The php.ini area to setup the mail() function points me here... where you do not tell me anything. dumb.
----
Server IP: 208.69.120.55
Probable Submitter: 97.92.63.44
----
Manual Page -- http://www.php.net/manual/en/mail.configuration.php
Edit -- https://master.php.net/note/edit/95391
Del: integrated -- https://master.php.net/note/delete/95391/integrated
Del: useless -- https://master.php.net/note/delete/95391/useless
Del: bad code -- https://master.php.net/note/dele
|
12/30/2009 11:46:10 PM
|
1
|
ericwants2k...@bugsout.org
|
note 95389 added to function.header
That is true.. however... on the other hand.. f*ck IE.
----
Server IP: 69.147.83.197
Probable Submitter: 195.159.103.46
----
Manual Page -- http://www.php.net/manual/en/function.header.php
Edit -- https://master.php.net/note/edit/95389
Del: integrated -- https://master.php.net/note/delete/95389/integrated
Del: useless -- https://master.php.net/note/delete/95389/useless
Del: bad code -- https://master.php.net/note/delete/95389/bad+code
Del: spam -- https://master.php.net/note/delete/95389/spam
Del: non-english -- https://master.php.net/note/delete/95389/non-engl
|
12/30/2009 11:16:12 PM
|
1
|
...@mailinator.com
|
note 95390 added to function.header
That is true.. however... on the other hand.. f*ck IE.
----
Server IP: 69.147.83.197
Probable Submitter: 195.159.103.46
----
Manual Page -- http://www.php.net/manual/en/function.header.php
Edit -- https://master.php.net/note/edit/95390
Del: integrated -- https://master.php.net/note/delete/95390/integrated
Del: useless -- https://master.php.net/note/delete/95390/useless
Del: bad code -- https://master.php.net/note/delete/95390/bad+code
Del: spam -- https://master.php.net/note/delete/95390/spam
Del: non-english -- https://master.php.net/note/delete/95390/non-engl
|
12/30/2009 11:16:11 PM
|
1
|
...@mailinator.com
|
note 95388 added to function.strtotime
When trying to find X months ago do not use strtotime("-$x months"); this will fail on 31 day months.
eg: running date("n",strtotime("-1 months")); on 31st of Dec will return 12 (Dec), not 11 (Nov) as I previously expected.
Instead you can use something like this:
<?php
$months_ago = 1; // change this to whatever
$month = date("n") - ($months_ago % 12);
$year = date("Y") - ($months_ago % 12);
?>
<?php
$months_ago = 15; // change this to whatever
$month = date("n") - ($months_ago % 12);
$year = date("Y") - ($months_ago % 12);
?>
----
Server IP: 117.55.229.1
Probable S
|
12/30/2009 11:01:09 PM
|
1
|
dtbakeratgm...@osu1.php.net
|
note 95387 added to function.ssh2-exec
ssh2_exec() is buggy as all get out. As posts below this one have noted, it frequently only returns a portion of the desired output and that's assuming it returns anything at all.
sleep() often fixes this but using sleep() in a for loop is a bad idea. jaimie at seoegghead dot com suggests using a "sentinel character" but not even that's fool proof. Try, for example, to cat an arbitrary file - can you guarantee that the "sentinel character" won't appear in the output? He also suggests that you can "escape the output via some encoding mechanism" but that doesn't work, either. Besides, ho
|
12/30/2009 5:21:06 PM
|
1
|
bothme...@gmail.com
|
note 95386 added to language.types.null
BTW, as of PHP 5.3, using '===' is still 5x faster for testing variables than using is_null().
Keep in mind, however, that is_null() tests expressions not simply variables:
http://www.php.net/manual/en/function.is-null.php#90782
----
Server IP: 64.71.164.2
Probable Submitter: 74.203.175.86
----
Manual Page -- http://www.php.net/manual/en/language.types.null.php
Edit -- https://master.php.net/note/edit/95386
Del: integrated -- https://master.php.net/note/delete/95386/integrated
Del: useless -- https://master.php.net/note/delete/95386/useless
Del: bad code -- https:/
|
12/30/2009 5:16:06 PM
|
1
|
CaiBl...@osu1.php.net
|
note 95385 added to function.posix-mkfifo
Object Oriented FIFO Communication process:
interface Communication {
public function receive($bytes = 1024);
public function getData();
public function clearData();
public function send($data);
}
class FIFOCommunication implements Communication {
private $fifos;
private $data;
static public function stream_fifo_open($fifoPath, $mode) {
if (pcntl_fork() == 0) {
if (! file_exists($fifoPath)) {
posix_mkfifo($fifoPath, $mode);
}
$fifo = fopen($fifoPath, 'w');
sleep(1);
exit(0);
}
else {
usleep(15);
return fopen($fifoPa
|
12/30/2009 1:23:14 PM
|
1
|
MauroTitim...@osu1.php.net
|
note 95384 added to function.strcmp
strcmp() is a binary safe comparison method.
Ex: int strcmp ( string $str1 , string $str2 )
The strcmp() function compares two strings as described above.
This function returns:
* 0 - if the two strings are equal
* <0 - if string1 is less than string2
* >0 - if string1 is greater than string2
----
Server IP: 69.147.83.197
Probable Submitter: 61.8.151.76
----
Manual Page -- http://www.php.net/manual/en/function.strcmp.php
Edit -- https://master.php.net/note/edit/95384
Del: integrated -- https://master.php.net/note/delete/95384/integrated
Del: useless
|
12/30/2009 12:27:07 PM
|
1
|
sanjaysahu.onl...@gmail.com
|
note 95383 added to function.ziparchive-addemptydir
to elaborate on what pagetronic said, if you try to use addEmptyDir on some (?all?) versions of Debian etch, you will get the error "call to undefined method ZipArchive::addEmptyDir".
I struggled with this for ages before realising that I could use addFromString to add a file to the archive, inside a new directory, without first creating the directory with addEmptyDir.
From pagetronic's post, it looks like this also works for addFile.
----
Server IP: 69.147.83.197
Probable Submitter: 88.107.30.203
----
Manual Page -- http://www.php.net/manual/en/function.ziparchive-addemptydir.php
|
12/30/2009 11:20:16 AM
|
1
|
wvoelc...@osu1.php.net
|
note 95382 added to function.uasort
A shorter syntax
for asc order
function cmp($a, $b)
{
return ($a - $b) ;
}
for desc order
function cmp($a, $b)
{
return ($b - $a) ;
}
----
Server IP: 69.147.83.197
Probable Submitter: 212.107.119.82
----
Manual Page -- http://www.php.net/manual/en/function.uasort.php
Edit -- https://master.php.net/note/edit/95382
Del: integrated -- https://master.php.net/note/delete/95382/integrated
Del: useless -- https://master.php.net/note/delete/95382/useless
Del: bad code -- https://master.php.net/note/delete/95382/bad+code
Del: spam -- https://mas
|
12/30/2009 10:49:06 AM
|
1
|
m3...@hotmail.com
|
note 95381 added to function.usort
Sorry abetter shorter syntax for descending order
function cmp($a, $b)
{
return !($a - $b) ? 0 : $b-$a;
}
----
Server IP: 69.147.83.197
Probable Submitter: 212.107.119.82
----
Manual Page -- http://www.php.net/manual/en/function.usort.php
Edit -- https://master.php.net/note/edit/95381
Del: integrated -- https://master.php.net/note/delete/95381/integrated
Del: useless -- https://master.php.net/note/delete/95381/useless
Del: bad code -- https://master.php.net/note/delete/95381/bad+code
Del: spam -- https://master.php.net/note/delete/95381/spam
Del: non-eng
|
12/30/2009 10:41:10 AM
|
1
|
m3...@hotmail.com
|
note 95380 added to function.stats-cdf-beta
Additional Notes, taken from source.
WHICH --> Integer indicating which of the next four argument
values is to be calculated from the others.
Legal range: 1..4
iwhich = 1 : Calculate P and Q from X,Y,A and B
iwhich = 2 : Calculate X and Y from P,Q,A and B
iwhich = 3 : Calculate A from P,Q,X,Y and B
iwhich = 4 : Calculate B from P,Q,X,Y and A
P <--> The integral from 0 to X of the chi-square
distribution.
Input range: [0, 1].
Q <--> 1-P.
Input range: [0, 1].
P + Q = 1.0.
X <--> Upper limit of integration of beta density.
Input range:
|
12/30/2009 8:16:17 AM
|
0
|
Anonym...@osu1.php.net
|
note 95379 added to language.pseudo-types
@phpguy at lifetoward dot com
At least in PHP 5.3.0 exactly this line works very well (proper functions 'reversesorter' and 'forwardsorter' given):
<?php
usort($array, ($reverse?'reversesorter':'forwardsorter'));
?>
----
Server IP: 69.147.83.197
Probable Submitter: 134.147.157.18
----
Manual Page -- http://www.php.net/manual/en/language.pseudo-types.php
Edit -- https://master.php.net/note/edit/95379
Del: integrated -- https://master.php.net/note/delete/95379/integrated
Del: useless -- https://master.php.net/note/delete/95379/useless
Del: bad code -- https://mast
|
12/30/2009 6:25:08 AM
|
1
|
...@osu1.php.net
|
note 95378 added to tutorial
this is wonderful tutorial .. i read it 3 times and get a fantastic results and sure i put a
copy of this lesson on my site here
http://www.adsense-secrets-tutorials.blogspot.com/
----
Server IP: 69.147.83.197
Probable Submitter: 41.237.24.58
----
Manual Page -- http://www.php.net/manual/en/tutorial.php
Edit -- https://master.php.net/note/edit/95378
Del: integrated -- https://master.php.net/note/delete/95378/integrated
Del: useless -- https://master.php.net/note/delete/95378/useless
Del: bad code -- https://master.php.net/note/delete/95378/bad+code
Del: spam
|
12/30/2009 4:07:16 AM
|
1
|
adsense-secrets-tutorials.blogs...@osu1.php.net
|
note 95377 added to function.session-start
For those of you running in problems with UTF-8 encoded files:
I was getting an error because of the BOM, although i set Dreamweaver to "save as" the without the BOM. It appears that DW will not change this setting in already existing files. After creating a new file withou the BOM, everything worked well.
I also recommend http://people.w3.org/rishida/utils/bomtester/index.php - a utility that remote checks for the presence of BOM.
----
Server IP: 92.43.200.200
Probable Submitter: 84.0.28.94
----
Manual Page -- http://www.php.net/manual/en/function.session-start.php
Edit --
|
12/30/2009 3:45:44 AM
|
0
|
i...@nospam.mmfilm.sk
|
note 95376 added to function.strlen
for utf8, why not just using mb_strlen :
$a= 'რეგისტრაცია';
$b=strlen($a);
=> $b = 33
$b=mb_strlen($a);
=> $b = 11 => good job no ?
----
Server IP: 89.31.146.176
Probable Submitter: 174.89.245.234
----
Manual Page -- http://www.php.net/manual/en/function.strlen.php
Edit -- https://master.php.net/note/edit/95376
Del: integrated -- https://master.php.net/note/delete/95376/integrated
Del: useless -- https://master.php.net/note/delete/95376/useless
Del: bad code -- https://master.php.net/note/delete/95376/bad+code
Del: spam -- https://master.php.net/note/dele
|
12/29/2009 9:41:10 PM
|
1
|
j...@osu1.php.net
|
note 95375 added to mysqli.store-result
It's not a bug in MySQL, the result set contains information about how executing the stored procedure went.
----
Server IP: 69.147.83.197
Probable Submitter: 213.100.35.60
----
Manual Page -- http://www.php.net/manual/en/mysqli.store-result.php
Edit -- https://master.php.net/note/edit/95375
Del: integrated -- https://master.php.net/note/delete/95375/integrated
Del: useless -- https://master.php.net/note/delete/95375/useless
Del: bad code -- https://master.php.net/note/delete/95375/bad+code
Del: spam -- https://master.php.net/note/delete/95375/spam
Del: non-engl
|
12/29/2009 8:39:19 PM
|
1
|
gar...@gmail.com
|
note 95374 added to reserved.variables.get
I created a function to help manage creating a hyperlink and modifying a parameter (or adding it to the query string). It preserves the current location of the parameter in the query string if it already exists, or appends it to the end. It does not duplicate parameters.
<?php
function changeQueryString($parameter, $value)
{
$queryString = $_SERVER["QUERY_STRING"];
if($queryString == "")
return $parameter."=".urlencode($value);
$ampExpl = explode("&", $queryString);
foreach($ampExpl as $i => $query)
{
$equExpl = explode("=", $query, 2);
$paramsAndVals[$equExpl[0]] = $
|
12/29/2009 8:36:33 PM
|
1
|
JohnG...@osu1.php.net
|
note 95373 added to language.oop5.overloading
To respond to a previous comment:
Yes, you could use __call to implement method polymorphism, but it's real purpose is for dynamic method generation (class polymorphism, perhaps?).
If you don't need dynamic method *names*, you can implement method polymorphism a lot more easily via the func_get_args() function within the declared method, for example:
class Foo {
public function bar() {
$c=count(func_get_args());
print "You called bar with $c arguments: ".join(", ",func_get_args()."\n";
}
}
----
Server IP: 69.147.83.197
Probable Submitter: 174.46.204.210
----
Manu
|
12/29/2009 6:36:17 PM
|
1
|
phpatkeithtylerdot...@osu1.php.net
|
note 95372 added to function.session-start
Unfortunately, after pulling my hair out trying to figure out why my application was working fine in every browser other than IE ( Internet Explorer) (Opera, Chrome, Firefox, Safari are what I've tested this in) - when using a DNS CNAME record (like a vanity name that is different from the DNS A record, which is the hostname of the server) sessions do not work correctly.
If you store a session var while on the CNAME:
vanity.domain.com and the hostname of the server is hosname.domain.com
Then try to call the variable from a different page, it will not find it because of the CNAME (I guess
|
12/29/2009 5:44:13 PM
|
1
|
jamestrowbri...@gmail.com
|
note 95371 added to function.ftp-nlist
Some complain that ftp_nlist, always return FALSE. I did experience this behavior myself, until I used ftp_pasv, which is useful if your client is behind a firewall (which most clients are now), then ftp_nlist worked just fine. I don't really know what are all the implications of using ftp_pasv, but if you read or experience that ftp_nlist, ftp_get, ftp_nb_get doesn't work, try adding the following:
ftp_pasv($conn_id,true);
----
Server IP: 64.71.164.2
Probable Submitter: 76.169.171.21
----
Manual Page -- http://www.php.net/manual/en/function.ftp-nlist.php
Edit -- https://master
|
12/29/2009 5:26:16 PM
|
0
|
Anonym...@osu1.php.net
|
note 95370 added to function.abs
To Berenoguz at superonline dot com:
Making this kind of check is useless, as -$y will always return the turned value. So you may use this instead :
<?php
function turn($x)
{
return -$x;
}
echo turn(-5) + turn(10);
?>
Which will output the same result faster.
----
Server IP: 89.31.146.176
Probable Submitter: 82.228.41.155
----
Manual Page -- http://www.php.net/manual/en/function.abs.php
Edit -- https://master.php.net/note/edit/95370
Del: integrated -- https://master.php.net/note/delete/95370/integrated
Del: useless -- https://master.php.net/note/delete/95370
|
12/29/2009 5:22:20 PM
|
0
|
sviscaino123athotmaildo...@osu1.php.net
|
note 95369 added to language.oop5.overloading
Franz: It doesn't say assignment chaining doesn't work, it simply says that the return value of __set is ignored. So this works fine:
<?php
$x = $obj->field = 7;
// $x == 7, $obj->field == 7
?>
On the other hand, this won't work as you (the author of class Test) expect, but will continue to behave as users of class Test expect:
<?php
class Test {
function __set($field, $value) {
return $this->$field = "foo";
}
}
$test = new Test();
$x = $test->field = 7;
// $x == 7, $test->field == "foo"
?>
This is generally a good thing; altering the behaviour of
|
12/29/2009 4:09:17 PM
|
1
|
mea...@gmail.com
|
note 95368 added to book.rar
Where can I get the mentioned php_rar.dll?
----
Server IP: 194.153.94.10
Probable Submitter: 157.161.31.18
----
Manual Page -- http://www.php.net/manual/en/book.rar.php
Edit -- https://master.php.net/note/edit/95368
Del: integrated -- https://master.php.net/note/delete/95368/integrated
Del: useless -- https://master.php.net/note/delete/95368/useless
Del: bad code -- https://master.php.net/note/delete/95368/bad+code
Del: spam -- https://master.php.net/note/delete/95368/spam
Del: non-english -- https://master.php.net/note/delete/95368/non-english
Del: in docs
|
12/29/2009 2:16:12 PM
|
0
|
J...@doe.com
|
note 95367 added to function.max
I disagree with sumeruter that in case of a recursive array php returnes the sub-array containing the highest value recursively. It checks the first value.
Eg.
$array = array(array(2, 3, 4), array(1, 4, 5));
print_r(max($array));
result:
Array ( [0] => 2 [1] => 3 [2] => 4 )
In sumeruter's example the maximal value was always in the array that has the highest first value as well.
----
Server IP: 69.147.83.197
Probable Submitter: 80.85.48.199
----
Manual Page -- http://www.php.net/manual/en/function.max.php
Edit -- https://master.php.net/note/edit/95367
Del: integrated
|
12/29/2009 2:03:15 PM
|
1
|
vendel...@gmail.com
|
note 95365 added to function.imagejpeg
This is the script i have been using for creating thumbnails of images ,but there is a problem that i can only display one image at time how many times i called it.
<?php
$file= "image.gif";
$old= @imagecreatefromjpeg("$file");
$weight= imageSX($old);
$height= imageSY($old);
$wn= 60;
$hn= 60;
if (!$old)
{
// We get errors from PHP's ImageCreate functions...
// So let's echo back the contents of the actual image.
readfile ($file);
}
else
{
$new = @imagecreatetruecolor($wn, $hn);
@imageCopyResized
|
12/29/2009 1:59:16 PM
|
1
|
Anonym...@osu1.php.net
|
note 95366 added to function.imagejpeg
This is the script i have been using for creating thumbnails of images ,but there is a problem that i can only display one image at time how many times i called it.
<?php
$file= "image.gif";
$old= @imagecreatefromjpeg("$file");
$weight= imageSX($old);
$height= imageSY($old);
$wn= 60;
$hn= 60;
if (!$old)
{
// We get errors from PHP's ImageCreate functions...
// So let's echo back the contents of the actual image.
readfile ($file);
}
else
{
$new = @imagecreatetruecolor($wn, $hn);
|
12/29/2009 1:59:16 PM
|
1
|
Anonym...@osu1.php.net
|
note 95364 added to function.md5
RE: gigatop100 at Hotmail dot com
While that function is going to make a 'secure' hash, it is also wasting time. Simply adding your extra salt to the end (and maybe one to the beginning) is all that is needed to make the hash more secure.
Everything else is just wasting cpu time.
----
Server IP: 192.41.40.227
Probable Submitter: 75.99.182.234
----
Manual Page -- http://www.php.net/manual/en/function.md5.php
Edit -- https://master.php.net/note/edit/95364
Del: integrated -- https://master.php.net/note/delete/95364/integrated
Del: useless -- https://master.php.net/note/
|
12/29/2009 1:14:46 PM
|
1
|
db...@gmail.com
|
note 95363 added to class.seekableiterator
Shorter:
<?php
$has = (is_callable(array($class, "seek")));
?>
----
Server IP: 212.124.37.9
Probable Submitter: 87.193.31.158
----
Manual Page -- http://www.php.net/manual/en/class.seekableiterator.php
Edit -- https://master.php.net/note/edit/95363
Del: integrated -- https://master.php.net/note/delete/95363/integrated
Del: useless -- https://master.php.net/note/delete/95363/useless
Del: bad code -- https://master.php.net/note/delete/95363/bad+code
Del: spam -- https://master.php.net/note/delete/95363/spam
Del: non-english -- https://master.php.net/note/de
|
12/29/2009 11:40:19 AM
|
1
|
unkown
|
note 95362 added to ref.bc
In reference to the factorial function posted previously: A recursive solution is almost any time worse than an iterative one. Plus, in this case it is easy to provide such a solution:
<?php
bcfact($x) {
$res = 1;
for ($i = $x; bccomp($i, '0') == 1; bcsub($i, '1')) {
$res = bcmul($res, $i);
}
return $res;
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 79.215.139.91
----
Manual Page -- http://www.php.net/manual/en/ref.bc.php
Edit -- https://master.php.net/note/edit/95362
Del: integrated -- https://master.php.n
|
12/29/2009 10:11:16 AM
|
1
|
MarkusWichm...@osu1.php.net
|
note 95361 added to function.date-default-timezone-set
that dude's code above needs to have a $offset = $offset*60*60; in it, like so:
<?php
function set_tz_by_offset($offset) {
$offset = $offset*60*60;
$abbrarray = timezone_abbreviations_list();
foreach ($abbrarray as $abbr) {
//echo $abbr."<br>";
foreach ($abbr as $city) {
//echo $city['offset']." $offset<br>";
if ($city['offset'] == $offset) { // remember to multiply $offset by -1 if you're getting it from js
date_default_timezone_set($city['timezone_id']);
|
12/29/2009 7:48:55 AM
|
1
|
iateadonutatgmaildot...@osu1.php.net
|
note 95360 added to function.mysql-close
I can also verify that mysql_close causes 5.3 (on Mac OS X Server 10.6) to crash with no error other than the server lost connection. This puzzled me for hours until I ran dozens of debug statements in my script to identify where the actual error was occurring.
Either the PHP documentation should be updated to reflect this, or a bug needs to be reported/fixed.
----
Server IP: 64.71.164.2
Probable Submitter: 24.7.95.133
----
Manual Page -- http://www.php.net/manual/en/function.mysql-close.php
Edit -- https://master.php.net/note/edit/95360
Del: integrated -- https://master.php
|
12/29/2009 7:43:11 AM
|
1
|
JonKoerber-call234bgatya...@osu1.php.net
|
note 95359 added to function.jdmonthname
You can get the month name by passing the month integer value to a simple function....
function getMonthName($Month){
$strTime=mktime(1,1,1,$Month,1,date("Y"));
return date("F",$strTime);
}
echo getMonthName(10);
Output:
October
----
Server IP: 59.162.86.123
Probable Submitter: 59.93.184.184
----
Manual Page -- http://www.php.net/manual/en/function.jdmonthname.php
Edit -- https://master.php.net/note/edit/95359
Del: integrated -- https://master.php.net/note/delete/95359/integrated
Del: useless -- https://master.php.net/note/delete/95359/useless
Del: bad code -
|
12/29/2009 7:40:22 AM
|
1
|
ukarma...@gmail.com
|
note 95358 added to function.exit
quick question i am not sure why this is working i just accidently was fooling around with some stuff, when a year i type in on a previous page and for some reason the exit breaks out of the inner IF statement and goes to the ELSE statement of the first IF block. can some one tell me why? It works correctly i am just curious why though. Is it because it is causing the first IF block to be already executed and exited out so it goes to the ELSE statement?
<?php
$year = $_POST['year'];
if ($year % 4 && $year % 100)
{
if ($year % 400 == false)
{
exit;
|
12/29/2009 6:07:11 AM
|
1
|
valetar...@live.com
|
note 95357 added to mysqli-result.free
If you are getting this error:
Internal SQL Bug: 2014, Commands out of sync; you can't run this command now
Then you never called this command in your script, and must call it before executing another stored procedure.
----
Server IP: 69.147.83.197
Probable Submitter: 24.29.21.97
----
Manual Page -- http://www.php.net/manual/en/mysqli-result.free.php
Edit -- https://master.php.net/note/edit/95357
Del: integrated -- https://master.php.net/note/delete/95357/integrated
Del: useless -- https://master.php.net/note/delete/95357/useless
Del: bad code -- https://master.php.
|
12/29/2009 1:04:13 AM
|
1
|
Vec...@ionisis.com
|
note 95356 added to language.oop5.magic
I realize a number of people probably don't see any utility at all in this, but if there is any interest from the community, I would be happy to implement another magic method __gettype(). I'm using objects with magic methods to model self-correcting and validating data. But, I want it to be as transparent to PHP as possible. As such, I'd like gettype($myObject) to return according to a __gettype() magic method rather than give back: "object."
Would this solution benefit anyone else?
----
Server IP: 69.147.83.197
Probable Submitter: 216.21.215.250
----
Manual Page -- http://www.php.
|
12/29/2009 12:21:16 AM
|
1
|
jmcent...@gmail.com
|
note 95355 added to install.windows.apache2
Apache 2.2 & php 5.2 on Win 7 (64) and Vista: If you have done everything correctly and still can't start the Apacheserver, consider whether anything (your Skype) listens to port 80. Thanks to http://www.thesitewizard.com/apache/install-apache-on-vista.shtml
----
Server IP: 69.147.83.197
Probable Submitter: 83.255.190.93
----
Manual Page -- http://www.php.net/manual/en/install.windows.apache2.php
Edit -- https://master.php.net/note/edit/95355
Del: integrated -- https://master.php.net/note/delete/95355/integrated
Del: useless -- https://master.php.net/note/delete/95355/usele
|
12/28/2009 10:26:11 PM
|
1
|
mik...@osu1.php.net
|
note 95354 added to timezones
If you're having trouble locating a timezone near you and / or your servers, try using this: http://www.timezoneconverter.com/cgi-bin/findzone/findzone.tzc
----
Server IP: 192.41.40.227
Probable Submitter: 24.21.86.44
----
Manual Page -- http://www.php.net/manual/en/timezones.php
Edit -- https://master.php.net/note/edit/95354
Del: integrated -- https://master.php.net/note/delete/95354/integrated
Del: useless -- https://master.php.net/note/delete/95354/useless
Del: bad code -- https://master.php.net/note/delete/95354/bad+code
Del: spam -- https://master.php.net/n
|
12/28/2009 9:53:21 PM
|
1
|
Ch...@COLOURlovers.com
|
note 95353 added to pdo.begintransaction
With Oracle, any structure statement will do an implicit commit.
So : ALTER TABLE "my_table" DROP COLUMN "my_column";
Can't be rolled back !
Hope this will save time for others
----
Server IP: 89.31.146.176
Probable Submitter: 82.227.124.74
----
Manual Page -- http://www.php.net/manual/en/pdo.begintransaction.php
Edit -- https://master.php.net/note/edit/95353
Del: integrated -- https://master.php.net/note/delete/95353/integrated
Del: useless -- https://master.php.net/note/delete/95353/useless
Del: bad code -- https://master.php.net/note/delete/95353/bad+code
Del
|
12/28/2009 9:45:38 PM
|
0
|
geom...@gmail.com
|
note 95352 added to mysqli-stmt.bind-result
I dont really see the point on using bind_param and methods as such if what you want is to get all the data as an array.
$this->conn = new mysqli ( $db['host'], $db['username'], $db['password'], $db['name'] );
$result = $this->conn->query( $queryStr );
while ( $row = $result->fetch_array() )
$this->result[] = $row;
And there you go: you have as an array the query. I havent checked it, but you get the idea and it should work. The pros are that you can access all the data like an array. The cons is that you have to extract all the data from the query.
Oh, wait. That is not a con
|
12/28/2009 9:14:12 PM
|
1
|
Davi...@osu1.php.net
|
note 95351 added to function.imap-mailboxmsginfo
Why does object->Messages, object->Recent and object->Unread are returned to 10 on my mailbox with a total of 10 messages and 2 of this unreaded?
----
Server IP: 69.147.83.197
Probable Submitter: 82.57.99.116
----
Manual Page -- http://www.php.net/manual/en/function.imap-mailboxmsginfo.php
Edit -- https://master.php.net/note/edit/95351
Del: integrated -- https://master.php.net/note/delete/95351/integrated
Del: useless -- https://master.php.net/note/delete/95351/useless
Del: bad code -- https://master.php.net/note/delete/95351/bad+code
Del: spam -- https://master
|
12/28/2009 8:29:22 PM
|
1
|
Tomm...@osu1.php.net
|
note 95350 added to function.imap-mailboxmsginfo
Why does object->Messages, object->Recent and object->Unread are returned to 10 on my mailbox with a total of 10 messages and 2 of this unreaded?
----
Server IP: 69.147.83.197
Probable Submitter: 82.57.99.116
----
Manual Page -- http://www.php.net/manual/en/function.imap-mailboxmsginfo.php
Edit -- https://master.php.net/note/edit/95350
Del: integrated -- https://master.php.net/note/delete/95350/integrated
Del: useless -- https://master.php.net/note/delete/95350/useless
Del: bad code -- https://master.php.net/note/delete/95350/bad+code
Del: spam -- https://master
|
12/28/2009 8:28:10 PM
|
1
|
Anonym...@osu1.php.net
|
note 95349 added to curl.installation
Just an additional note for Windows XP installations ...
The instructions others have courteously given still lack one small item for those who have the Windows/system32 directory as the repository for the .dll files concerned with php_curl.
Go to the ext directory of your php installation and copy php_curl.dll to the Windows/system32 folder after you have followed the advise given elsewhere.
So ...
1) remove ';' from extension=php_curl.dll in php.ini
2) ensure that ssleay32.dll and libeay32.dll are in Windows/system32.
3) Copy php_curl.dll into Windows\System32 as well.
G'da
|
12/28/2009 7:04:14 PM
|
0
|
wixelb...@yahoo.com
|
note 95347 added to function.strip-tags
<?php
function strip_bbcode($post)
{
return preg_replace('/\[(\/){0,1}([^\[]+)\]/', '', $post);
}
?>
It's a small function to remove all bb tags from a string.
Usage:
<?php
echo strip_bbcode("[quote]Hi, I've got a [b]very big[/b] problem. I can't enter the site [url]http://php.net/[/url].[/quote] Can you enter [i]any other[/i] websites?");
?>
outputs:
Hi, I've got a very big problem. I can't enter the site http://php.net/ Can you enter any other websites?
----
Server IP: 194.24.174.37
Probable Submitter: 79.163.138.234
----
Manual Page -- http://www.php.net/manual/en/fun
|
12/28/2009 6:21:23 PM
|
1
|
nieprzekli...@gmail.com
|