php-general Digest 4 Nov 2010 08:09:04 -0000 Issue 7020
Topics (messages 309267 through 309282):
Re: include() and duplicate function definition
309267 by: Peter Lind
309268 by: David Nelson
309269 by: Thijs Lensselink
309272 by: David Nelson
309273 by: Steve Staples
309274 by: David Nelson
Re: Execute a php page and don't wait for it to finish
309270 by: Ferdi
Re: Integrating zend-facebook error
309271 by: nitesh nandy
Apache mod_pagespeed
309275 by: Thiago H. Pojda
309276 by: Shreyas Agasthya
309277 by: Daniel P. Brown
309278 by: Jim Jagielski
Problems converting strings with 0 to integer
309279 by: robert mena
309280 by: Nicholas Kell
309281 by: Alexander Holodny
Pros/Cons of using mysqli prepared statments
309282 by: Tamara Temple
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
That's not going to happen. My point was you could check in the original
file if the function is defined and if not then define it.
On Nov 3, 2010 11:55 AM, "David Nelson" <[email protected]> wrote:
> Hi Peter, :-)
>
> On Wed, Nov 3, 2010 at 18:44, Peter Lind <[email protected]> wrote:
>> You can check with function_exists to see if a function is already
defined.
>> If not, create it.
>
> The function is definitely already defined, I just need to replace it
> without touching the file in which it's defined...
>
> David Nelson
--- End Message ---
--- Begin Message ---
Hi, :-)
On Wed, Nov 3, 2010 at 19:29, Peter Lind <[email protected]> wrote:
> That's not going to happen. My point was you could check in the original
> file if the function is defined and if not then define it.
OK, thanks, Thijs and Peter, it looks like I'm trying to do something
that is not currently possible in PHP. Time for some lateral thinking.
:-)
David Nelson
--- End Message ---
--- Begin Message ---
On Wed, 3 Nov 2010 19:53:52 +0800, David Nelson
<[email protected]> wrote:
Hi, :-)
On Wed, Nov 3, 2010 at 19:29, Peter Lind <[email protected]>
wrote:
That's not going to happen. My point was you could check in the
original
file if the function is defined and if not then define it.
OK, thanks, Thijs and Peter, it looks like I'm trying to do something
that is not currently possible in PHP. Time for some lateral
thinking.
:-)
David Nelson
David,
I re-read your original post. And noticed you include the function
inside your child action.php
Is there a special reason for that? You want to overwrite the original
function in a child theme.
probably to get different functionality. So why do you need the
original function?
Just create your action.php and define the same function.
// include '../sometheme/functions/actions.php';
function foo($arg_1, $arg_2, /* ..., */ $arg_n) {
echo "All my new code.\n";
}
It's code duplication. But i don't think themes should have
dependencies to one an other.
You could also create a actions.php file outside the themes folder.
wp-content/shared-functions/action.php
And then in your themes do:
theme 1
include "shared-function/action.php";
foo();
theme 2
include "shared-function/action.php";
foo();
--- End Message ---
--- Begin Message ---
Hi Thijs, :-)
On Wed, Nov 3, 2010 at 20:38, Thijs Lensselink <[email protected]> wrote:
> I re-read your original post. And noticed you include the function inside
> your child action.php
> Is there a special reason for that? You want to overwrite the original
> function in a child theme.
> probably to get different functionality. So why do you need the original
> function?
>
> Just create your action.php and define the same function.
It's a WordPress issue. When theme updates become available from the
original vendor, you can update them from within the admin backend. In
that case, any hacks you've applied (such as removing a function) get
overwritten. So the evangelized solution is to create a child theme.
The child theme incorporates only files that you've added or changed,
with the original parent theme being used for all others.
Easy peasy if you want to *add* a function.
But, if you want to *modify* a function, you're faced with the problem
of the original function still being present in the parent theme files
and of your having to define a function of the same name in your child
theme (if you change the function name, you then have to hack other
code further upstream, and the work involved becomes not worth the
bother). Somehow, I would need to make my hacked function *replace*
the original function, *without* touching the original function...
It seems like that's not possible and I'll have to find another
solution... unless my explanation gives you any good ideas?
Just to put the dots on the I's, the original "actions.php" contains a
lot of *other* functions that I don't want to touch, and that I do
want to leave exposed to the updates process. It's just one single
function I want to hack...
Sticky problem, huh? :-)
In any case, thanks for your kind help, :-)
David Nelson
P.S. Sorry about the direct mails: I keep forgetting to hit the
"Replly to all" button.
--- End Message ---
--- Begin Message ---
On Thu, 2010-11-04 at 00:00 +0800, David Nelson wrote:
> Hi Thijs, :-)
>
> On Wed, Nov 3, 2010 at 20:38, Thijs Lensselink <[email protected]> wrote:
> > I re-read your original post. And noticed you include the function inside
> > your child action.php
> > Is there a special reason for that? You want to overwrite the original
> > function in a child theme.
> > probably to get different functionality. So why do you need the original
> > function?
> >
> > Just create your action.php and define the same function.
>
> It's a WordPress issue. When theme updates become available from the
> original vendor, you can update them from within the admin backend. In
> that case, any hacks you've applied (such as removing a function) get
> overwritten. So the evangelized solution is to create a child theme.
> The child theme incorporates only files that you've added or changed,
> with the original parent theme being used for all others.
>
> Easy peasy if you want to *add* a function.
>
> But, if you want to *modify* a function, you're faced with the problem
> of the original function still being present in the parent theme files
> and of your having to define a function of the same name in your child
> theme (if you change the function name, you then have to hack other
> code further upstream, and the work involved becomes not worth the
> bother). Somehow, I would need to make my hacked function *replace*
> the original function, *without* touching the original function...
>
> It seems like that's not possible and I'll have to find another
> solution... unless my explanation gives you any good ideas?
>
> Just to put the dots on the I's, the original "actions.php" contains a
> lot of *other* functions that I don't want to touch, and that I do
> want to leave exposed to the updates process. It's just one single
> function I want to hack...
>
> Sticky problem, huh? :-)
>
> In any case, thanks for your kind help, :-)
>
> David Nelson
>
> P.S. Sorry about the direct mails: I keep forgetting to hit the
> "Replly to all" button.
>
I am curious on how this would work, if for some reason they were using
a different template? the function you want to "overwrite", wont be
used, and therefore, wouldn't your app/template/whatever be updated
improperly than waht you expect it to be?
Just curious...
--- End Message ---
--- Begin Message ---
Hi guys, :-)
Just FYI, I got this answer from the theme dev:
"David,
You don't need the include statement. If you create your function in
wp-content/themes/suffusion-child/functions.php it will get
automatically included.
Secondly, using the same function name wouldn't work, because it would
require me to encase the original function definition in actions.php
in a "function_exists" clause. I would suggest using a different
function name, then using remove_action to remove the older action and
add_action to add the new action."
(http://www.aquoid.com/forum/viewtopic.php?f=4&t=3070)
I'm not yet confident about how to actually implement this in code...
Any tips or advice would be gratefully heard.
On Thu, Nov 4, 2010 at 00:13, Steve Staples <[email protected]> wrote:
> I am curious on how this would work, if for some reason they were using
> a different template? the function you want to "overwrite", wont be
> used, and therefore, wouldn't your app/template/whatever be updated
> improperly than waht you expect it to be?
Steve, maybe the above informs? In any case, the function to be
overwritten is likely to remain fairly stable...
All the best, :-)
David Nelson
--- End Message ---
--- Begin Message ---
On 19 October 2010 18:50, Ferdi <[email protected]> wrote:
> Hi List,
>
> I have a php page that updates data from one database to another when it is
> run.
> My query is, how can I trigger the execution of this update page from
> another php / javascript without the calling page having to wait for the
> update page to finish?
> Basically, I think the update page needs to use:
> ignore_user_abort(1);
> set_time_limit(0); // I don't think the script will take more than 1 min.
>
> At the other end I found this:
> 1)
> http://www.mindraven.com/blog/php/run-a-php-script-in-the-background-using-ajax/
> 2) On that page a user suggested using *pclose(popen(‘/usr/bin/php
> /path/to/something.php > /dev/null &’, ‘r’)*
> * *However, I need this to be usable on windows servers also.
> 3) Finally, would pcntl_exec, pcntl_fork, exec or something be useful for
> me?
>
> Which of the above 3 options is the better one?
> Other suggestions are welcome :)
>
>
Hi List,
Sorry this took so long, but I wanted to close the loop (and maybe ease some
one else's trouble :-)).
I didn't think much about the die(header('Location:
run_this_even_if_user_aborts.php')) call I was actually using to get this
working.
When I carefully looked up php.net for header, I realised it was a browser
redirect! Now wonder the script would work some times but not always.
It's clear now that every time the script worked was because I waited long
enough for the browser to be redirected before killing the page.
I finally settled on using jquery's ajax calls.
Thanks once again to the repliers.
Ferdi
--- End Message ---
--- Begin Message ---
Can you paste a dump of complete error stack ?
On Sun, Oct 31, 2010 at 10:12 PM, Yuri Yarlei <[email protected]> wrote:
> Hi,
>
> I'm trying to integrate facebook to show the wall in a site.
>
> ok, i generate the auth_token here:
>
> https://login.facebook.com/code_gen.php?api_key=API_KEY&v=1.0
>
> And put the rest connection configuration here:
>
> $facebookArr = array(
> "appapikey" => $appapikey,
> "appidkey" => $appidkey,
> "appsecret" => $appsecret,
> "appcallbackurl" => $appcallbackurl,
> 'cookie' => true,
> 'token' => $token
>
> );
> $fb = new FacebookRestClient($facebookArr['appapikey'],
> $facebookArr['appsecret']);
>
> $result = $fb->call_method('facebook.auth.getSession',
> array('auth_token' =>$facebookArr['token'],
> 'generate_session_secret' => true));
>
> Its work, but only the first time, if i refresh i get this exception:
>
> exception 'FacebookRestClientException' with message 'Invalid parameter'
>
> If i generate the token again, its work for the first time again.
>
> Please someone have any recent tutorial to integrate facebook to some php
> site?
>
>
>
> Atenciosamente,
> Yuri Yarlei.
> www.yuriyarlei.net (under construction)
> Programmer PHP, JAVA, CSS, ORACLE 10g, PostgreSQL;
> Next step is the SCJP.
> "Se você ainda não esta com dor de cabeça, é por que ainda cabe um pouco
> mais de conhecimento."
>
--
Regards,
Nitesh Nandy
--- End Message ---
--- Begin Message ---
Guys,
Google announced this
morning<http://googlewebmastercentral.blogspot.com/2010/11/make-your-websites-run-faster.html>their
mod_pagespeed <http://code.google.com/speed/page-speed/docs/module.html> to
improve Apache's performance. It really looks promising, what do you guys
think?
Me and Daniel Brown will be running some tests with it, let us know if you'd
like to join us. :)
Google mentions 2x faster loading times, but they don't mention CPU cost.
What do you think it will break?
Cheers,
Thiago Henrique Pojda
+55 41 8856-7925
--- End Message ---
--- Begin Message ---
Thiago,
I would like to join this. Let me know how I can help you with this. Please
be explicit with your requests so that we can totally test it and see if it
could pose any risk to acceleration services provided by CDNs.
Regards,
Shreyas
On Wed, Nov 3, 2010 at 11:51 PM, Thiago H. Pojda <[email protected]>wrote:
> Guys,
>
> Google announced this
> morning<
> http://googlewebmastercentral.blogspot.com/2010/11/make-your-websites-run-faster.html
> >their
> mod_pagespeed <http://code.google.com/speed/page-speed/docs/module.html>
> to
> improve Apache's performance. It really looks promising, what do you guys
> think?
>
> Me and Daniel Brown will be running some tests with it, let us know if
> you'd
> like to join us. :)
>
> Google mentions 2x faster loading times, but they don't mention CPU cost.
>
> What do you think it will break?
>
>
> Cheers,
> Thiago Henrique Pojda
> +55 41 8856-7925
>
--
Regards,
Shreyas Agasthya
--- End Message ---
--- Begin Message ---
On Wed, Nov 3, 2010 at 14:48, Shreyas Agasthya <[email protected]> wrote:
> Thiago,
>
> I would like to join this. Let me know how I can help you with this. Please
> be explicit with your requests so that we can totally test it and see if it
> could pose any risk to acceleration services provided by CDNs.
I've yet to read the specs behind it (I was out of the office),
but from the overview I did see, it should not only be of no detriment
to CDNs. In fact, Google is working with an existing company,
Cotendo, to integrate the core into their CDN.
--
</Daniel P. Brown>
Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/
--- End Message ---
--- Begin Message ---
They are doing a preso about it @ ApacheCon.
On Wed, Nov 03, 2010 at 03:34:01PM -0400, Daniel P. Brown wrote:
> On Wed, Nov 3, 2010 at 14:48, Shreyas Agasthya <[email protected]> wrote:
> > Thiago,
> >
> > I would like to join this. Let me know how I can help you with this. Please
> > be explicit with your requests so that we can totally test it ?and see if it
> > could pose any risk to acceleration services provided by CDNs.
>
> I've yet to read the specs behind it (I was out of the office),
> but from the overview I did see, it should not only be of no detriment
> to CDNs. In fact, Google is working with an existing company,
> Cotendo, to integrate the core into their CDN.
>
> --
> </Daniel P. Brown>
> Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
> (866-) 725-4321
> http://www.parasane.net/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--
===========================================================================
Jim Jagielski [|] [email protected] [|] http://www.jaguNET.com/
"Great is the guilt of an unnecessary war" ~ John Adams
--- End Message ---
--- Begin Message ---
Hi,
I have a text file (utf-8 encoded) which contains lines with numbers and
text separated by \t. I need to convert the numbers that contains 0 (at
left) to integers.
For some reason one line that contains 00000002 is casted to 0 instead of 2.
Bellow the output of the cast (int) $field[0] where I get this from
explode each line.
0 00000002
4 00000004
--- End Message ---
--- Begin Message ---
On Nov 3, 2010, at 4:22 PM, robert mena wrote:
> Hi,
>
> I have a text file (utf-8 encoded) which contains lines with numbers and
> text separated by \t. I need to convert the numbers that contains 0 (at
> left) to integers.
>
> For some reason one line that contains 00000002 is casted to 0 instead of 2.
> Bellow the output of the cast (int) $field[0] where I get this from
> explode each line.
>
> 0 00000002
> 4 00000004
My first guess is wondering how you are grabbing the strings from the file.
Seems to me like it would just drop the zeros on the left by default. Are you
including the \t in the string by accident? If so, that may be hosing it.
Otherwise, have you tried ltrim on it?
Ex:
$_castableString = ltrim($_yourString, '0');
// Now cast
--- End Message ---
--- Begin Message ---
To exclude unexcepted behavior in case of wrongly formated input data,
it would be much better to use such type-casting method:
intval(ltrim(trim($inStr), '0'))
2010/11/3, Nicholas Kell <[email protected]>:
>
> On Nov 3, 2010, at 4:22 PM, robert mena wrote:
>
>> Hi,
>>
>> I have a text file (utf-8 encoded) which contains lines with numbers and
>> text separated by \t. I need to convert the numbers that contains 0 (at
>> left) to integers.
>>
>> For some reason one line that contains 00000002 is casted to 0 instead of
>> 2.
>> Bellow the output of the cast (int) $field[0] where I get this from
>> explode each line.
>>
>> 0 00000002
>> 4 00000004
>
>
>
> My first guess is wondering how you are grabbing the strings from the file.
> Seems to me like it would just drop the zeros on the left by default. Are
> you including the \t in the string by accident? If so, that may be hosing
> it. Otherwise, have you tried ltrim on it?
>
> Ex:
>
> $_castableString = ltrim($_yourString, '0');
>
> // Now cast
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
I'm wondering what the advantages/disadvantage of using prepared
statements with mysqli are. I'm used to using the mysqli::query and
mysqli::fetch_assoc functions to deal with retrieving data and bulding
my sql statement in php code.
Tamara Temple
-- aka tamouse__
[email protected]
"May you never see a stranger's face in the mirror."
--- End Message ---