php-general Digest 13 Feb 2007 15:49:49 - Issue 4624
Topics (messages 248793 through 248807):
Re: Filtering _REQUEST.. Why is this bad?
248793 by: Robert Cummings
248794 by: J R
248795 by: Chris Shiflett
Re: Iterators
248796 by: Marc Weber
static functions
What did I miss here?
In case somebody else wants to know.
I've found some examples in php sources ( ext/spl/tests/array_009.phpt )
This is the way to accomplish this:
$array = array(1, 2 = array(21, 22 = array(221, 222), 23 = array(231)),
3);
$dir = new RecursiveIteratorIterator(new
Why can't I use static functions in array_map?
Example:
?php
class Dummy
{
static public function T($a)
{
echo T called with $a\n;
return $a+2;
}
}
function t($a)
{
echo t called with $a\n;
return $a*2;
}
echo 'invoking Dummy::T works fine : ', Dummy::T(3),\n;
Marc Weber wrote:
Why can't I use static functions in array_map?
Example:
?php
class Dummy
{
static public function T($a)
{
echo T called with $a\n;
return $a+2;
}
}
function t($a)
{
echo t called with $a\n;
return $a*2;
}
echo 'invoking Dummy::T works
http://de.php.net/~helly/php/ext/spl/interfaceRecursiveIterator.html
This piece of code
?php
$array = array(1, 2 = array(21, 22 = array(221, 222), 23 = array(231)),
3);
$dir = new RecursiveIteratorIterator(new ArrayIterator($array));
foreach ($dir as $file) {
Hi,
Having this array:
$arr = array(
'my var'='My Value'
);
Notice the space in 'my var'.
Converted to object:
$obj = (object)$arr;
How can I access $arr['my var'] in $obj ?
-thanks!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit:
On Tue, Feb 13, 2007 at 12:02:10PM +0200, Eli wrote:
Hi,
Having this array:
$arr = array(
'my var'='My Value'
);
Notice the space in 'my var'.
Converted to object:
$obj = (object)$arr;
How can I access $arr['my var'] in $obj ?
This works but there may be much
Eli wrote:
Hi,
Having this array:
$arr = array(
'my var'='My Value'
);
Notice the space in 'my var'.
Converted to object:
$obj = (object)$arr;
How can I access $arr['my var'] in $obj ?
-thanks!
print $obj-{'my var'};
$obj-{'my var'} = 'My New Value';
print $obj-{'my var'};
--
On Tue, Feb 13, 2007 at 11:54:41AM +0100, Marc Weber wrote:
I've implemented a simple walk function which seems to be even easier
using php.
So consider this thread beeing no longer a problem :)
Marc
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit:
# [EMAIL PROTECTED] / 2007-02-13 11:54:41 +0100:
http://de.php.net/~helly/php/ext/spl/interfaceRecursiveIterator.html
This piece of code
?php
$array = array(1, 2 = array(21, 22 = array(221, 222), 23 = array(231)),
3);
$dir = new
Hi all,
I'm getting these errors:
[04-Dec-2006 18:21:56] PHP Warning: Unknown: The session id contains
illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in Unknown
on line 0
[04-Dec-2006 18:21:56] PHP Warning: Unknown: Failed to write session data
(files). Please verify that the
You may check same discussion at
http://bugs.php.net/bug.php?id=31184edit=1
On Mon, 4 Dec 2006, M.Ozan Hazer wrote:
Hi all,
I'm getting these errors:
[04-Dec-2006 18:21:56] PHP Warning: Unknown: The session id contains
illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in
is it true that echo is a bit faster than print()? in general, when we don't
need a return value, which one is better to choose?
Cheers,
Danial Rahmanzadeh
On Tue, 2007-02-13 at 19:19 +0330, Danial Rahmanzadeh wrote:
is it true that echo is a bit faster than print()? in general, when we don't
need a return value, which one is better to choose?
Yes, echo is faster than print. I would suggest echo over print since it
is shorter and faster :)
As referenced in the manual ( http://us2.php.net/manual/en/function.echo.php ),
check out this url:
http://www.faqts.com/knowledge_base/view.phtml/aid/1/fid/40
Short story, there is a difference, but the speed difference is negligable.
If anyone cares, I prefer echo too. Not sure why. Shorter
If I use add slashes, it strips everything, I just want to replace all the
double quotes with slash double quote but this, of course, throws errors:
str_replace(,\,$code);
Thanks!
negligible.. blarg spelling. :)
= = = Original message = = =
As referenced in the manual ( http://us2.php.net/manual/en/function.echo.php ),
check out this url:
http://www.faqts.com/knowledge_base/view.phtml/aid/1/fid/40
Short story, there is a difference, but the speed difference is
At 7:57 PM +0100 2/12/07, Marc Weber wrote:
On Mon, 12 Feb 2007 18:02:41 +0100, [EMAIL PROTECTED] wrote:
Is there an easy way in php to round to the nearest 500?
Yeah
$rouned = round($val/500) * 500;
I've always questioned the round() function.
I believe it has a downward bias, am I wrong?
On 2/13/07, blackwater dev [EMAIL PROTECTED] wrote:
If I use add slashes, it strips everything, I just want to replace all the
double quotes with slash double quote but this, of course, throws errors:
str_replace(,\,$code);
Thanks!
Try this
$string = 'Hello person. How are you?';
You could use addslashes():
http://us3.php.net/manual/en/function.addslashes.php
Or, the code you mentioned below, could be rewritten like:
str_replace(\,\\,$code);
or
str_replace('','\',$code);
And if you're doing it for a MySQL query call, then you want to use
mysql-real-escape-string()
echo is slightly faster than print and it takes multiple arguments so
instead of:
echo 'p' . $test . '/p';
you can do
echo 'p' , $test , '/p';
which should be faster, and I say 'should' just because as print should be
slower because it has to go into the trouble of setting up a return
For downward rounding, you'd always want to use floor() and use ceil() for
rounding up. round() rounds up on a 5, down on a 4 and below.
Example:
echo round(141.074, 2); // 141.07
echo round(141.065, 2); // 141.07
I thought round() (or maybe it was a rounding function in another language or
snip
Supposedly this is an accounting trick that
ultimatley works out in the end for proper rounding of money
values.
Yeah works out for who? Bet it doesn't for the guy paying :P
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
hah yeah, always worth a little skepticism, but it seemed to make some kind of
sense. If you always round up or always round down, that's obviously not
right and you end up losing potentially a lot of money or over-estimating the
money involved.
Founding up for 5 through 9 and down for 0
Dear all, I was just creating two upload pages,both will upload files into
directory named bin.
./bin/ -- directory where the files uploaded
./admin/upload.php-- I wrote path as ../bin/
./userupload.php-- I wrote path as bin/
I was confused because
[EMAIL PROTECTED] wrote:
hah yeah, always worth a little skepticism, but it seemed to make some kind of
sense. If you always round up or always round down, that's obviously not
right and you end up losing potentially a lot of money or over-estimating the
money involved.
Founding up for 5
Ok, screw work.. it's snowing out anyway (not that that makes a real difference
to doing PHP work inside), curiosity got the better of me.
btw.. the banker rounding code here was pulled from the round() manual page.
It's not what I read before, but it's the same concept:
function
Ahh.. good call.
http://en.wikipedia.org/wiki/Rounding
Apprently it's called banker's rounding or statistician's rounding and is a
little more complicated than just looking at the odd/even of the digit being
arounded.
This is starting to get into some heavy math theory and scary stuff that
- Original Message -
From: Jon Anderson [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
hah yeah, always worth a little skepticism, but it seemed to make some
kind of sense. If you always round up or always round down, that's
obviously not right and you end up losing potentially a lot
I don't buy zero doesn't count. But again, this is getting into serious
math. It should be good enough to say 0-4 = 0, 5-9 = 10, but if you don't keep
strict high precision throughout the whole process and round at every step,
things are going to be off no matter what. It's just a matter of
Is it possible to assign form[ upldFile ] = C:\somepath\somefile
or
form[ upldFile ] = $_FILES['userfile']['name']
The value attribute of the input type=file... tag is not able to be
altered or pre-populated for obvious security reasons.
The script which does the validation is the same one
Miles Thompson wrote:
When a file upload fails, not because of a problem with the upload itself,
is there anyway of assigning the value captured by
input name=upldFile type=file
when the form is redisplayed?
The failure may not be due to a problem with the file being uploaded, but
Brad Fuller wrote:
Is it possible to assign form[ upldFile ] = C:\somepath\somefile
or
form[ upldFile ] = $_FILES['userfile']['name']
The value attribute of the input type=file... tag is not able to be
altered or pre-populated for obvious security reasons.
The script which does the
Thanks guys - I guess the staging area is the way we'll go. (This is from
gmail, I'm not used to it, so if I included all of the prev msgs, please
forgive me.)
Thanks - Miles
When a file upload fails, not because of a problem with the upload itself,
is there anyway of assigning the value captured by
input name=upldFile type=file
when the form is redisplayed?
The failure may not be due to a problem with the file being uploaded, but
because the user failed to
How can I upload files up to 40MB with a html post form? (without a ftp
client)
Please, remember
1. My hosting provider has up to 120 seconds apache timeout
2. My hosting provider has up to 10MB to upload files in php.ini
Any kind of ideas?
Regards
Mauricio M.
[snip]
1. My hosting provider has up to 120 seconds apache timeout
2. My hosting provider has up to 10MB to upload files in php.ini
Any kind of ideas?
[/snip]
Get a new provider?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
On Mon, February 12, 2007 8:41 pm, J R wrote:
it is not adviced to do filtering on _REQUEST getting data in general
from
it actually. It is much better to specify where your data is coming
from (
e.g. _POST or _GET). This is because variable _REQUST contains all the
data
from the cookies,
On Sat, February 10, 2007 3:19 pm, pub wrote:
To all PHP experts,
Do any of you also know how to play bridge?
If yes, which do you think is harder to learn, PHP or bridge?
Bridge is way more harder to learn.
Especially all those weird bidding conventions with no rationale.
--
Some people
Hey all,
I read on php.net about resources, the type
returned from mysql_query(), and was trying locate
the best way to get the result set back from a
query into an array.
Is simply looping through the result set with
mysql_fetch_assoc() the common way to do this?
As great as PHP is with
On Tue, February 13, 2007 5:34 pm, Skip Evans wrote:
I read on php.net about resources, the type
returned from mysql_query(), and was trying locate
the best way to get the result set back from a
query into an array.
Is simply looping through the result set with
mysql_fetch_assoc() the
i agree, no argument there.
Data coming from user should always be considered malicious. I'm just
pointing out one reason why not use _REQUEST. but there are intance _REQUEST
variable can be useful (just be very careful). Regarding _GET and _POST
using same name, there are instance this can be
Richard Lynch wrote:
The most efficient way is Don't do that. :-)
Simply loop through the results and do whatever you want to do with
them, and don't put them into an array at all.
This makes perfect sense.
However, I am currently writing an abstraction
layer for a project that will later
# [EMAIL PROTECTED] / 2007-02-13 17:43:10 -0700:
Richard Lynch wrote:
The most efficient way is Don't do that. :-)
Simply loop through the results and do whatever you want to do with
them, and don't put them into an array at all.
This makes perfect sense.
However, I am currently
On Tue, 2007-02-13 at 18:22 -0600, Richard Lynch wrote:
#2
loop through mysql result set to build $array
perform some kind of calculation upon $array
In this case, it's USUALLY much more efficient to write an SQL query
to perform the calculation.
Databases are highly optimized for this
45 matches
Mail list logo