php-general Digest 2 Feb 2011 10:31:20 -0000 Issue 7163

Topics (messages 311116 through 311129):

Re: Pulling from Multiple Databases
        311116 by: David Hutto
        311117 by: Alexis
        311118 by: David Hutto
        311119 by: Steve Staples

nl2br problem
        311120 by: Donovan Brooke
        311121 by: Daniel Brown
        311122 by: David Hutto
        311123 by: Donovan Brooke
        311128 by: David Robley
        311129 by: Ashley Sheridan

Re: Detecting Multi-Scope Variables
        311124 by: Brad Lorge
        311125 by: Ashley Sheridan
        311126 by: Brad Lorge
        311127 by: David Harkness

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
I'd pass the db's to a threaded function that processes each db's info
in an algorithmic order.

-- 
The lawyer in me says argue...even if you're wrong. The scientist in
me... says shut up, listen, and then argue. But the lawyer won on
appeal, so now I have to argue due to a court order.

Furthermore, if you could be a scientific celebrity, would you want
einstein sitting around with you on saturday morning, while you're
sitting in your undies, watching Underdog?...Or better yet, would
Einstein want you to violate his Underdog time?

Can you imagine Einstein sitting around in his underware? Thinking
about the relativity between his pubic nardsac, and his Fruit of the
Looms, while knocking a few Dorito's crumbs off his inner brilliant
white thighs, and hailing E = mc**2, and licking the orangy,
delicious, Doritoey crust that layered his genetically rippled
fingertips?

But then again, J. Edgar Hoover would want his pantyhose intertwined
within the equation.

However, I digress, momentarily.

But Einstein gave freely, for humanity, not for gain, other than
personal freedom.

An equation that benefited all, and yet gain is a personal product.

Also, if you can answer it, is gravity anymore than interplanetary static cling?

--- End Message ---
--- Begin Message ---
Bloody Hell!!

How many lines is the footer in your email response!!!

I make it almost ten times longer than the reply itself....talk about abominable netiquette, and I have purposely put this response at the top as after all footers do go at the bottom of an email :)

Do you even NEED a footer with nothing but inane comments in it?

Alexis
On 01/02/11 11:54, David Hutto wrote:
> I'd pass the db's to a threaded function that processes each db's info
> in an algorithmic order.
>
> -- The lawyer in me says argue...even if you're wrong. The scientist in
> me... says shut up, listen, and then argue. But the lawyer won on
> appeal, so now I have to argue due to a court order. Furthermore, if you
> could be a scientific celebrity, would you want einstein sitting around
> with you on saturday morning, while you're sitting in your undies,
> watching Underdog?...Or better yet, would Einstein want you to violate
> his Underdog time? Can you imagine Einstein sitting around in his
> underware? Thinking about the relativity between his pubic nardsac, and
> his Fruit of the Looms, while knocking a few Dorito's crumbs off his
> inner brilliant white thighs, and hailing E = mc**2, and licking the
> orangy, delicious, Doritoey crust that layered his genetically rippled
> fingertips? But then again, J. Edgar Hoover would want his pantyhose
> intertwined within the equation. However, I digress, momentarily. But
> Einstein gave freely, for humanity, not for gain, other than personal
> freedom. An equation that benefited all, and yet gain is a personal
> product. Also, if you can answer it, is gravity anymore than
> interplanetary static cling?
> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
> http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
> Do you even NEED a footer with nothing but inane comments in it?
>

It's probably an overcompensation for a small penis.

> Alexis
> On 01/02/11 11:54, David Hutto wrote:
>> I'd pass the db's to a threaded function that processes each db's info
>> in an algorithmic order.
>>
>> -- The lawyer in me says argue...even if you're wrong. The scientist in
>> me... says shut up, listen, and then argue. But the lawyer won on
>> appeal, so now I have to argue due to a court order. Furthermore, if you
>> could be a scientific celebrity, would you want einstein sitting around
>> with you on saturday morning, while you're sitting in your undies,
>> watching Underdog?...Or better yet, would Einstein want you to violate
>> his Underdog time? Can you imagine Einstein sitting around in his
>> underware? Thinking about the relativity between his pubic nardsac, and
>> his Fruit of the Looms, while knocking a few Dorito's crumbs off his
>> inner brilliant white thighs, and hailing E = mc**2, and licking the
>> orangy, delicious, Doritoey crust that layered his genetically rippled
>> fingertips? But then again, J. Edgar Hoover would want his pantyhose
>> intertwined within the equation. However, I digress, momentarily. But
>> Einstein gave freely, for humanity, not for gain, other than personal
>> freedom. An equation that benefited all, and yet gain is a personal
>> product. Also, if you can answer it, is gravity anymore than
>> interplanetary static cling?
>> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
>> http://www.php.net/unsub.php
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
The lawyer in me says argue...even if you're wrong. The scientist in
me... says shut up, listen, and then argue. But the lawyer won on
appeal, so now I have to argue due to a court order.

Furthermore, if you could be a scientific celebrity, would you want
einstein sitting around with you on saturday morning, while you're
sitting in your undies, watching Underdog?...Or better yet, would
Einstein want you to violate his Underdog time?

Can you imagine Einstein sitting around in his underware? Thinking
about the relativity between his pubic nardsac, and his Fruit of the
Looms, while knocking a few Dorito's crumbs off his inner brilliant
white thighs, and hailing E = mc**2, and licking the orangy,
delicious, Doritoey crust that layered his genetically rippled
fingertips?

But then again, J. Edgar Hoover would want his pantyhose intertwined
within the equation.

However, I digress, momentarily.

But Einstein gave freely, for humanity, not for gain, other than
personal freedom.

An equation that benefited all, and yet gain is a personal product.

Also, if you can answer it, is gravity anymore than interplanetary static cling?

--- End Message ---
--- Begin Message ---
-- purposely top posting as well --
just think, here in ontario, we have UBB... where Bell is proposing a 25
cap on usage... you sir, are killing my usage!!!!!

:)

On Tue, 2011-02-01 at 12:18 -0700, Alexis wrote:
> Bloody Hell!!
> 
> How many lines is the footer in your email response!!!
> 
> I make it almost ten times longer than the reply itself....talk about 
> abominable netiquette, and I have purposely put this response at the top 
> as after all footers do go at the bottom of an email :)
> 
> Do you even NEED a footer with nothing but inane comments in it?
> 
> Alexis
> On 01/02/11 11:54, David Hutto wrote:
>  > I'd pass the db's to a threaded function that processes each db's info
>  > in an algorithmic order.
>  >
>  > -- The lawyer in me says argue...even if you're wrong. The scientist in
>  > me... says shut up, listen, and then argue. But the lawyer won on
>  > appeal, so now I have to argue due to a court order. Furthermore, if you
>  > could be a scientific celebrity, would you want einstein sitting around
>  > with you on saturday morning, while you're sitting in your undies,
>  > watching Underdog?...Or better yet, would Einstein want you to violate
>  > his Underdog time? Can you imagine Einstein sitting around in his
>  > underware? Thinking about the relativity between his pubic nardsac, and
>  > his Fruit of the Looms, while knocking a few Dorito's crumbs off his
>  > inner brilliant white thighs, and hailing E = mc**2, and licking the
>  > orangy, delicious, Doritoey crust that layered his genetically rippled
>  > fingertips? But then again, J. Edgar Hoover would want his pantyhose
>  > intertwined within the equation. However, I digress, momentarily. But
>  > Einstein gave freely, for humanity, not for gain, other than personal
>  > freedom. An equation that benefited all, and yet gain is a personal
>  > product. Also, if you can answer it, is gravity anymore than
>  > interplanetary static cling?
>  > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
>  > http://www.php.net/unsub.php
> 



--- End Message ---
--- Begin Message ---
Hello,

I have CMS form that allows HTML for the body of a site.

To keep the form somewhat WYSIWYG, I am using the
nl2br() function for displaying:

nl2br($t_body)

This works great for normal stuff.. but for pages with tables
etc.. it creates a lot of extra "<br />'s" :-).

I thought about doing an if statement.. if $t_body contains <table> then
don't use nl2br().. but I'm thinking there has got to be a better way... because pages that use both WYSIWYG returns in the form AND tables would then not display well.

Any thoughts?

Thanks,
Donovan


--
D Brooke

--- End Message ---
--- Begin Message ---
On Tue, Feb 1, 2011 at 14:42, Donovan Brooke <li...@euca.us> wrote:
> Hello,
>
> I have CMS form that allows HTML for the body of a site.
>
> To keep the form somewhat WYSIWYG, I am using the
> nl2br() function for displaying:
>
> nl2br($t_body)
>
> This works great for normal stuff.. but for pages with tables
> etc.. it creates a lot of extra "<br />'s" :-).
[snip!]
>
> Any thoughts?

    Absolutely.  Look into employing TinyMCE or CKEditor (or the older
FCKEditor) so you don't have to do so much server-side processing.
This will only apply to pages moving forward, mind you, not for
displaying existing table data.  You'll need to make the determination
if it's right for your specific case.

-- 
</Daniel P. Brown>
Network Infrastructure Manager
Documentation, Webmaster Teams
http://www.php.net/

--- End Message ---
--- Begin Message ---
If project names are indications of programmer's Freudian insights,
then what is the FCKEditor?

--- End Message ---
--- Begin Message ---
Daniel Brown wrote:
[snip]
     Absolutely.  Look into employing TinyMCE or CKEditor (or the older
FCKEditor) so you don't have to do so much server-side processing.
This will only apply to pages moving forward, mind you, not for
displaying existing table data.  You'll need to make the determination
if it's right for your specific case.


I probably should have went that route! I'm really bad about
looking for existing solutions. ;-)  Instead, I
I am using a conditional where if the content contains
a table, then don't use nl2br... then I told the admin
that if they use tables in their body content, then they will
have to include the <br />'s themselves.

---
$t_tablecount = substr_count($t_body, '<table');
$t_endtablecount = substr_count($t_body, '</table');

if (($t_tablecount > 0) && ($t_endtablecount > 0)) {
  print "$t_body";
} else {
  print nl2br("$t_body");
}
---

I guess that will work for now.

Donovan


--
D Brooke

--- End Message ---
--- Begin Message ---
David Hutto wrote:

> If project names are indications of programmer's Freudian insights,
> then what is the FCKEditor?

Perhaps that questions should be asked of the lead developer's parents, who
had the temerity to name him Frederico Caldeira Knabben.


Cheers
-- 
David Robley

"I need an injection," Tom pleaded in vain.
Today is Pungenday, the 33rd day of Chaos in the YOLD 3177. 


--- End Message ---
--- Begin Message ---
On Tue, 2011-02-01 at 14:24 -0600, Donovan Brooke wrote:

> Daniel Brown wrote:
> [snip]
> >      Absolutely.  Look into employing TinyMCE or CKEditor (or the older
> > FCKEditor) so you don't have to do so much server-side processing.
> > This will only apply to pages moving forward, mind you, not for
> > displaying existing table data.  You'll need to make the determination
> > if it's right for your specific case.
> 
> 
> I probably should have went that route! I'm really bad about
> looking for existing solutions. ;-)  Instead, I
> I am using a conditional where if the content contains
> a table, then don't use nl2br... then I told the admin
> that if they use tables in their body content, then they will
> have to include the <br />'s themselves.
> 
> ---
> $t_tablecount = substr_count($t_body, '<table');
> $t_endtablecount = substr_count($t_body, '</table');
> 
> if (($t_tablecount > 0) && ($t_endtablecount > 0)) {
>    print "$t_body";
> } else {
>    print nl2br("$t_body");
> }
> ---
> 
> I guess that will work for now.
> 
> Donovan
> 
> 
> -- 
> D Brooke
> 


Is it that you're having <br/> tags inserted inside of <table></table>
tags but outside of <tr> and <td> tags?

If so, you could maybe run a final check over the whole output string
and check for any <br/> tags that immediately precede a cell or row tag.
It's a little sloppy but might work.

Failing that, you could maybe apply some css to preserve line breaks as
they were entered, although this may produce varying results depending
on the exact content:

div.content
{
    white-space: pre;
}

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
Perhaps my question was not as succinct as it could have been.

Basically, can you think of a means through which to detect whether or not a
variable is currently present in multiple scopes.

IE:

<?php

$bob = "fish";

echo is_multiscoped($bob); //False

function something()
{
     echo is_multiscoped($fish); //False
     gloabal $bob;
     echo is_multiscoped($bob);//True
}

function getJam($&ref)
{
    echo is_multiscoped($ref);//True
}

$jim = "nothing special";

echo is_multiscoped($jim); //False

getJam($jim);


?>

On Tue, Feb 1, 2011 at 7:12 PM, Tommy Pham <tommy...@gmail.com> wrote:

> > -----Original Message-----
> > From: Brad Lorge [mailto:b...@lorge.com.au]
> > Sent: Monday, January 31, 2011 9:53 PM
> > To: php-gene...@lists.php.net
> > Subject: [PHP] Detecting Multi-Scope Variables
> >
> > Hello All,
> >
> > I am new to the list so please be gentle :)
> >
> > I am working on a PHP framework and have run up against a functionality
> > hurdle which I keep falling at. Basically, I have three mechanisms which
> all
> > function in a similar way and require this functionality: templating,
> event
> > handling and "action handling". Within the core code of the application,
> as
> > is common with many applications with plugin architecture, I pass a
> number
> > of parameters to functions which have hooked into a particular "event".
> Part
> > of the mechanism is that parameters can be passed by reference to allow
> > for the listeners to make modifications.
> >
> > $username="bob";$account_type="ISV";$password="fishbum";
> >
> > register_action_listener('process_user', function($username,
> > $account_type, $password){$username.="." . $account_type;} // Or
> > whatever
> >
> > call_action('process_user', &$username, &$account_type, &$password);
> > //Result: $username == "bob.ISV"
>
> I think you meant to use [1].
>
> >
> > Now, what I am trying to do is establish a method to prevent the "hook"
> > functions from making changes by reference without reference explicitly
> > being passed to them by the calling code.
> >
>
> Perhaps you  should review [2] and see if your logic works with your
> 'call_action'.
>
> > I have thought of a method which simply makes a copy of all the
> parameters
> > for each listener within call_action(), however what I would really love
> is a
> > function which returns whether or not the supplied variable is available
> in
> > multiple scopes or is in the original scope which it was initialized in.
> > Does anyone know of a way to achieve this?
> >
> > Regards,
> > Brad
>
> Happy coding,
> Tommy
>
> [1] http://php.net/call_user_func
> [2] http://php.net/references
>
>
>

--- End Message ---
--- Begin Message ---
"Brad Lorge" <b...@lorge.com.au> wrote:

>Perhaps my question was not as succinct as it could have been.
>
>Basically, can you think of a means through which to detect whether or
>not a
>variable is currently present in multiple scopes.
>
>IE:
>
><?php
>
>$bob = "fish";
>
>echo is_multiscoped($bob); //False
>
>function something()
>{
>     echo is_multiscoped($fish); //False
>     gloabal $bob;
>     echo is_multiscoped($bob);//True
>}
>
>function getJam($&ref)
>{
>    echo is_multiscoped($ref);//True
>}
>
>$jim = "nothing special";
>
>echo is_multiscoped($jim); //False
>
>getJam($jim);
>
>
>?>
>
>On Tue, Feb 1, 2011 at 7:12 PM, Tommy Pham <tommy...@gmail.com> wrote:
>
>> > -----Original Message-----
>> > From: Brad Lorge [mailto:b...@lorge.com.au]
>> > Sent: Monday, January 31, 2011 9:53 PM
>> > To: php-gene...@lists.php.net
>> > Subject: [PHP] Detecting Multi-Scope Variables
>> >
>> > Hello All,
>> >
>> > I am new to the list so please be gentle :)
>> >
>> > I am working on a PHP framework and have run up against a
>functionality
>> > hurdle which I keep falling at. Basically, I have three mechanisms
>which
>> all
>> > function in a similar way and require this functionality:
>templating,
>> event
>> > handling and "action handling". Within the core code of the
>application,
>> as
>> > is common with many applications with plugin architecture, I pass a
>> number
>> > of parameters to functions which have hooked into a particular
>"event".
>> Part
>> > of the mechanism is that parameters can be passed by reference to
>allow
>> > for the listeners to make modifications.
>> >
>> > $username="bob";$account_type="ISV";$password="fishbum";
>> >
>> > register_action_listener('process_user', function($username,
>> > $account_type, $password){$username.="." . $account_type;} // Or
>> > whatever
>> >
>> > call_action('process_user', &$username, &$account_type,
>&$password);
>> > //Result: $username == "bob.ISV"
>>
>> I think you meant to use [1].
>>
>> >
>> > Now, what I am trying to do is establish a method to prevent the
>"hook"
>> > functions from making changes by reference without reference
>explicitly
>> > being passed to them by the calling code.
>> >
>>
>> Perhaps you  should review [2] and see if your logic works with your
>> 'call_action'.
>>
>> > I have thought of a method which simply makes a copy of all the
>> parameters
>> > for each listener within call_action(), however what I would really
>love
>> is a
>> > function which returns whether or not the supplied variable is
>available
>> in
>> > multiple scopes or is in the original scope which it was
>initialized in.
>> > Does anyone know of a way to achieve this?
>> >
>> > Regards,
>> > Brad
>>
>> Happy coding,
>> Tommy
>>
>> [1] http://php.net/call_user_func
>> [2] http://php.net/references
>>
>>
>>

In more low level languages like C and C++ you could look at the actual value 
of the pointer, I'm not sure that that is available in php.


Thanks
Ash
http://www.ashleysheridan.co.uk
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

--- End Message ---
--- Begin Message ---
Hmm, would this then be a question for internals?

On Wed, Feb 2, 2011 at 9:59 AM, Ashley Sheridan 
<a...@ashleysheridan.co.uk>wrote:

> "Brad Lorge" <b...@lorge.com.au> wrote:
>
> >Perhaps my question was not as succinct as it could have been.
> >
> >Basically, can you think of a means through which to detect whether or
> >not a
> >variable is currently present in multiple scopes.
> >
> >IE:
> >
> ><?php
> >
> >$bob = "fish";
> >
> >echo is_multiscoped($bob); //False
> >
> >function something()
> >{
> >     echo is_multiscoped($fish); //False
> >     gloabal $bob;
> >     echo is_multiscoped($bob);//True
> >}
> >
> >function getJam($&ref)
> >{
> >    echo is_multiscoped($ref);//True
> >}
> >
> >$jim = "nothing special";
> >
> >echo is_multiscoped($jim); //False
> >
> >getJam($jim);
> >
> >
> >?>
> >
> >On Tue, Feb 1, 2011 at 7:12 PM, Tommy Pham <tommy...@gmail.com> wrote:
> >
> >> > -----Original Message-----
> >> > From: Brad Lorge [mailto:b...@lorge.com.au]
> >> > Sent: Monday, January 31, 2011 9:53 PM
> >> > To: php-gene...@lists.php.net
> >> > Subject: [PHP] Detecting Multi-Scope Variables
> >> >
> >> > Hello All,
> >> >
> >> > I am new to the list so please be gentle :)
> >> >
> >> > I am working on a PHP framework and have run up against a
> >functionality
> >> > hurdle which I keep falling at. Basically, I have three mechanisms
> >which
> >> all
> >> > function in a similar way and require this functionality:
> >templating,
> >> event
> >> > handling and "action handling". Within the core code of the
> >application,
> >> as
> >> > is common with many applications with plugin architecture, I pass a
> >> number
> >> > of parameters to functions which have hooked into a particular
> >"event".
> >> Part
> >> > of the mechanism is that parameters can be passed by reference to
> >allow
> >> > for the listeners to make modifications.
> >> >
> >> > $username="bob";$account_type="ISV";$password="fishbum";
> >> >
> >> > register_action_listener('process_user', function($username,
> >> > $account_type, $password){$username.="." . $account_type;} // Or
> >> > whatever
> >> >
> >> > call_action('process_user', &$username, &$account_type,
> >&$password);
> >> > //Result: $username == "bob.ISV"
> >>
> >> I think you meant to use [1].
> >>
> >> >
> >> > Now, what I am trying to do is establish a method to prevent the
> >"hook"
> >> > functions from making changes by reference without reference
> >explicitly
> >> > being passed to them by the calling code.
> >> >
> >>
> >> Perhaps you  should review [2] and see if your logic works with your
> >> 'call_action'.
> >>
> >> > I have thought of a method which simply makes a copy of all the
> >> parameters
> >> > for each listener within call_action(), however what I would really
> >love
> >> is a
> >> > function which returns whether or not the supplied variable is
> >available
> >> in
> >> > multiple scopes or is in the original scope which it was
> >initialized in.
> >> > Does anyone know of a way to achieve this?
> >> >
> >> > Regards,
> >> > Brad
> >>
> >> Happy coding,
> >> Tommy
> >>
> >> [1] http://php.net/call_user_func
> >> [2] http://php.net/references
> >>
> >>
> >>
>
> In more low level languages like C and C++ you could look at the actual
> value of the pointer, I'm not sure that that is available in php.
>
>
> Thanks
> Ash
> http://www.ashleysheridan.co.uk
> --
> Sent from my Android phone with K-9 Mail. Please excuse my brevity.
>

--- End Message ---
--- Begin Message ---
I think you can use reflection [1] to block the hooks from using & in their
parameter lists. This way the clients must use & to pass a reference. This
is definitely possible for function/method callbacks [2], but I'm not sure
about 5.3 closures [3].

David

[1] http://www.php.net/manual/en/reflectionparameter.ispassedbyreference.php
[2]
http://www.php.net/manual/en/language.pseudo-types.php#language.types.callback
[3] http://www.php.net/manual/en/functions.anonymous.php

--- End Message ---

Reply via email to