|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general Digest 20 Aug 2005 21:55:43 -0000 Issue 3636
php-general-digest-help
lists.php.net
Date: Sat Aug 20 2005 - 16:55:43 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 20 Aug 2005 21:55:43 -0000 Issue 3636
Topics (messages 220999 through 221015):
Super globals ?
220999 by: Wong HoWang
221000 by: Jasper Bryant-Greene
221001 by: Kevin Waterson
221002 by: Jasper Bryant-Greene
221005 by: Kevin Waterson
221007 by: Jasper Bryant-Greene
221008 by: Wong HoWang
Re: Document source code for PHP5
221003 by: Markus Fischer
Re: preg_match
221004 by: John Nichel
221006 by: Jasper Bryant-Greene
__sleep, __wakeup and persistent connections
221009 by: Marcus Bointon
Re: Week Days
221010 by: Robert Cummings
error while running com
221011 by: sangram
Re: PHP MySQL insert
221012 by: areguera
apache sessions
221013 by: Bawt T. Eggdrop
build sql query struture and values from form fields
221014 by: Andras Kende
221015 by: Greg Donald
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
Dear all,
Hello, I want to know that is there any way to create a super global in PHP?
Please help!
Thanks.
attached mail follows:
Wong HoWang wrote:
> Hello, I want to know that is there any way to create a super global in PHP?
Only with the runkit extension. Take a look:
http://www.php.net/runkit
Jasper
attached mail follows:
This one time, at band camp, Jasper Bryant-Greene <jasper
bryant-greene.name> wrote:
> Wong HoWang wrote:
> > Hello, I want to know that is there any way to create a super global in PHP?
>
> Only with the runkit extension. Take a look:
>
> http://www.php.net/runkit
This is exactly what $_GLOBALS is for, why not use it?
Kevin
--
"Democracy is two wolves and a lamb voting on what to have for lunch.
Liberty is a well-armed lamb contesting the vote."
attached mail follows:
Kevin Waterson wrote:
> This one time, at band camp, Jasper Bryant-Greene <jasper
bryant-greene.name> wrote:
>
>
>>Wong HoWang wrote:
>>
>>>Hello, I want to know that is there any way to create a super global in PHP?
>>
>>Only with the runkit extension. Take a look:
>>
>>http://www.php.net/runkit
>
>
> This is exactly what $_GLOBALS is for, why not use it?
Because he asked for superglobals, not globals. $GLOBALS (not $_GLOBALS)
happens to be an example of a superglobal.
Jasper
attached mail follows:
This one time, at band camp, Jasper Bryant-Greene <jasper
bryant-greene.name> wrote:
> Because he asked for superglobals, not globals. $GLOBALS (not $_GLOBALS)
meh, force of habit
> happens to be an example of a superglobal.
and variable can be set within its scope, so why not use it?
As we see in the manual at $GLOBALS _is_ a super global and available
to all scopes within the script.
http://www.php.net/manual/en/reserved.variables.php#reserved.variables.globals
it refers to $GLOBALS as " This is a 'superglobal', or automatic global, variable. "
gotta love the php manual
kevin
--
"Democracy is two wolves and a lamb voting on what to have for lunch.
Liberty is a well-armed lamb contesting the vote."
attached mail follows:
Kevin Waterson wrote:
> This one time, at band camp, Jasper Bryant-Greene <jasper
bryant-greene.name> wrote:
>
>
>>Because he asked for superglobals, not globals. $GLOBALS (not $_GLOBALS)
>
> meh, force of habit
>
>>happens to be an example of a superglobal.
>
>
> and variable can be set within its scope, so why not use it?
> As we see in the manual at $GLOBALS _is_ a super global and available
> to all scopes within the script.
> http://www.php.net/manual/en/reserved.variables.php#reserved.variables.globals
> it refers to $GLOBALS as " This is a 'superglobal', or automatic global, variable. "
>
> gotta love the php manual
Exactly Kevin. What the OP wanted was to create another superglobal,
just like $GLOBALS. The contents of $GLOBALS refer to the global
variables, which are *not* all superglobals. The only superglobals by
default in PHP (apart from $GLOBALS) are $_SERVER, $_GET, $_POST, and so on.
He asked a question, and I provided the answer. Why he wants to do it is
another question, but telling him to "use $GLOBALS" isn't answering his
question, it's answering a different question, namely how to access the
global variables.
Jasper
attached mail follows:
yes, I am asking how to start my own super global...
And even a PHP beginner know that $GLOBALS is a array containing all the
global variables and it is used in a function or a class. So I think no one
will ask a question here which the answer is simply $GLOBALS.
Any finally, thanks Jasper for the answer.
"Jasper Bryant-Greene" <jasper
bryant-greene.name>
wrote:43071D3D.5060603
bryant-greene.name...
> Kevin Waterson wrote:
>> This one time, at band camp, Jasper Bryant-Greene
>> <jasper
bryant-greene.name> wrote:
>>
>>
>>>Because he asked for superglobals, not globals. $GLOBALS (not $_GLOBALS)
>>
>> meh, force of habit
>>
>>>happens to be an example of a superglobal.
>>
>>
>> and variable can be set within its scope, so why not use it?
>> As we see in the manual at $GLOBALS _is_ a super global and available
>> to all scopes within the script.
>> http://www.php.net/manual/en/reserved.variables.php#reserved.variables.globals
>> it refers to $GLOBALS as " This is a 'superglobal', or automatic global,
>> variable. "
>>
>> gotta love the php manual
>
> Exactly Kevin. What the OP wanted was to create another superglobal, just
> like $GLOBALS. The contents of $GLOBALS refer to the global variables,
> which are *not* all superglobals. The only superglobals by default in PHP
> (apart from $GLOBALS) are $_SERVER, $_GET, $_POST, and so on.
>
> He asked a question, and I provided the answer. Why he wants to do it is
> another question, but telling him to "use $GLOBALS" isn't answering his
> question, it's answering a different question, namely how to access the
> global variables.
>
> Jasper
attached mail follows:
Denis Gerasimov wrote:
>>Can someone recommend a documentation tool which supports the new PHP5
>>syntax?
>
>
> PHPDocumentor (http://www.phpdoc.org/) does. I am using Zend Studio
> integrated version and it works fine.
Then I'm wondering what I'm doing wrong because it puts interface
function definitions into the global function scope ...
- Markus
attached mail follows:
Richard Lynch wrote:
> On Fri, August 19, 2005 7:03 am, Matthew Weier O'Phinney wrote:
>
>>* John Nichel <john
kegworks.com> :
>>
>>>Richard Lynch wrote:
>>>
>>>>On Thu, August 18, 2005 2:50 pm, Jon wrote:
>>>>
>>>>>preg_match_all("/Charges \s\s+ $total x (.+) /siU", $single,
>>>>>$from_invoice);
>>>>
>>>>I would recommend using \\s instead of \s -- While \s doesn't have
>>>
>>>any
>>>
>>>>meaning in PHP strings, so PHP just figures you must have meant
>>>
>>>\\s
>>><snip>
>>>
>>>But in perl type regex's, the \s is a space. Without testing it, I
>>>don't think \\s would match what the OP was looking for (I *think*
>
>
> But Perl isn't going to *SEE* \\s !!!
>
> PHP is going to *EAT* \\ and make \ out of it.
>
> That's why \ is an escape character in PHP.
>
> It's also an escape character in Perl/PCRE.
>
> Some days I think PHP's escape character should have been | or
> something, just so this topic wouldn't come up every damn month.
<snip>
Personally, I have never used \\ in PCRE when looking for things like
spaces (\s), word boundraries (\b), etc. and it's all worked out fine.
--
By-Tor.com
...it's all about the Rush
http://www.by-tor.com
attached mail follows:
John Nichel wrote:
> Personally, I have never used \\ in PCRE when looking for things like
> spaces (\s), word boundraries (\b), etc. and it's all worked out fine.
It will work fine, but only because those (\s and \b) just happen to not
be special characters in PHP *at this time*.
It's sloppy programming because the backslash is known to be a special
character, and \s or \b could conceivably become special characters at
some time in the future. It's unlikely, but possible.
Not only that, but it makes it more likely that you'll forget and put \n
when you meant \\n, \r when you meant \\r, \t when you meant \\t, and so
on...
Jasper
attached mail follows:
I'm sorting out some code to handle session object storage,
particularly where the objects contain DB connections. I've found
lots of articles that go on about how __sleep should clean up db
stuff, close connections etc and how __wakeup should reconnect, but
weirdly enough I've not found a single concrete example of doing this!
It's also not quite clear how this behaviour interacts with
persistent connections. For example, If I do this:
class foo {
protected $db;
public function __construct() {
$this->db = mysql_pconnect(....);
}
protected function __wakeup() {
$this->db = mysql_pconnect(....);
}
protected function __sleep() {
mysql_close($this->db);
$this->db = NULL;
return array();
}
}
given that the connection is persistent, and may thus be used by
other scripts, is calling mysql_close a particularly bad idea? Should
I just not bother closing the connection, letting PHP deal with it -
the object will not attempt to re-use the stale connection because it
will get a new instance courtesy of __wakeup when unserialized.
I'm also unclear about how __sleep acts in subclasses - it seems that
as soon as I have a __sleep function in a base class, I don't have
any choice but to implement __sleep functions in every subclass of
it, even if I don't want them to do anything that would not be done
if __sleep were not defined. in the exampel, the base class has no
properties to save, so it returns an empty array from __sleep, but
that's unlikely to be useful for a subclass that does have properties
(and serializing an object without any properties is pointless!).
Ideas?
Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
marcus
synchromedia.co.uk | http://www.synchromedia.co.uk
attached mail follows:
On Sat, 2005-08-20 at 03:15, benc11
gmail.com wrote:
> Rob,
>
> I tried your code below, but it didn't work. I put the number of week days
> in $addWeekdays variable. Am I doing something wrong or is there an error in
> the code? Appreciate your help!
There's an error... I didn't account for the starting day being a
weekend day :) The following should work (somewhat tested) and I also
removed locale dependency from it (check for "Sat" and "Sun").
<?php
//
// For every 5 days to add we wrap a week and are right back where we
// started so...
//
$addWeekdays = isset( $argv[1] ) ? $argv[1] : 0; // command line for fun
$start = time();
$addWeeks = (int)($addWeekdays / 5);
$addWeekDays = ($addWeekdays % 5);
$daySeconds = (24 * 60 * 60);
$final = $start + ($addWeeks * 7 * $daySeconds);
$day = date( 'w', $final );
if( $day == 1 ) // Saturday
{
$final += ($daySeconds * 2);
}
else
if( $day == 0 ) // Sunday
{
$final += $daySeconds;
}
else
{
while( $addWeekDays > 0 )
{
$final += $daySeconds;
$day = date( 'w', $final );
if( $day != '0' && $day != '6' )
{
$addWeekDays--;
}
}
}
echo 'Start: '.date( 'Y-m-d (D)', $start )."\n";
echo 'Final: '.date( 'Y-m-d (D)', $final )."\n";
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
Hi,
i had uploaded the com application on win2003 server with word 2003
installed.It runs perfect The traffic of word files increases or other
reasons the following message starts displaying.
Warning: (null)(): Unable to obtain IDispatch interface for CLSID
{000209FF-0000-0000-C000-000000000046}: Server execution failed in
c:\inetpub\wwwroot\localuser\sound1007\www\com.php on line 15
Unable to instanciate Word
If the server is rebooted again the application starts without errors.
Pls help me what will be the problem.
Sangram.
attached mail follows:
On 8/19/05, Richard Lynch <ceo
l-i-e.com> wrote:
> On Fri, August 19, 2005 12:56 pm, areguera wrote:
> >> could you suggest something about Latin characters and portability?.
>
> As I understand it, or not, more likely, you want to configure your
> MySQL server to use UTF-8, and your MySQL client to use UTF-8 and
> pretty much everything to use UTF-8, and then you can convert your
> data to UTF-8 and its gonna store it in a way that you'll be able to
> convert back to Latin-1 or whatever you like.
>
> At least, that's what Mark Matthews of MySQL A/B said in his talk
> about this at our more recent Chicago MySQL User Group meeting.
>
> You may want to take this question to the i18n PHP list, where people
> who have actually done it hang out. :-)
thanks Richard, I'll make a walk around i18n php list...:) ... it
seems that utf-8 is the solution for internationalization, but I ask
my self what would happen with prior versions of mysql without utf-8
support? and how to design an application to both run as utf-8 or
iso-8859-1 in the require situation. can it be?
>
> --
> Like Music?
> http://l-i-e.com/artists.htm
>
>
>
attached mail follows:
im trying to change my session backend for apache from files to mysql.
is there something php provides that allows a php script to execute
before each page gets loaded in apache. if not i have to edit hundreds
of php files...theres gotta be an easier way. thanks.
attached mail follows:
Hello,
I would like to create the mysql insert query for my html form fields,
I have a small problem it will have an extra , at the end of $sqlstruct
And extra "" at $sqldata..
Anyone can give a hint ?
////////////
foreach ($_POST as $variable=>$value){
$sqlstruct.=$variable",";
$sqldata.=$value."\"','\"";
}
$query="insert into db ($sqlstruct) VALUES ($sqldata)";
////////////
Best regards,
Andras Kende
http://www.kende.com
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.10.13/78 - Release Date: 8/19/2005
attached mail follows:
On 8/20/05, Andras Kende <andras
kende.com> wrote:
> I would like to create the mysql insert query for my html form fields,
> I have a small problem it will have an extra , at the end of $sqlstruct
> And extra "" at $sqldata..
>
> Anyone can give a hint ?
>
> ////////////
> foreach ($_POST as $variable=>$value){
> $sqlstruct.=$variable",";
> $sqldata.=$value."\"','\"";
> }
>
> $query="insert into db ($sqlstruct) VALUES ($sqldata)";
$k = implode( ',', array_keys( $_POST ) );
$v = implode( ',', array_values( $_POST ) );
$sql = "INSERT INTO db ( $k ) VALUES ( $v )";
I'd never do something like this though, just begs for SQL injection.
--
Greg Donald
Zend Certified Engineer
MySQL Core Certification
http://destiney.com/
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]