php-general Digest 3 May 2008 23:47:05 -0000 Issue 5439

Topics (messages 273835 through 273847):

Re: Any Running Simple Ajax Sample for Php
        273835 by: paragasu

Re: web based chat app
        273836 by: paragasu
        273846 by: Nitsan Bin-Nun

How to create accessible by PHP
        273837 by: Todd Cary
        273838 by: Todd Cary
        273841 by: David Otton

Complex escape string
        273839 by: cyaugin
        273840 by: Casey
        273842 by: Craige Leeder
        273843 by: Steven R. Ringwald

Question on PHP 6 and static calls to instance methods.
        273844 by: Adam Richardson
        273845 by: Adam Richardson

new $foo->className(); Class name must be a valid object or a   string
        273847 by: Jack Bates

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 ---
On Sat, May 3, 2008 at 4:31 AM, Jon L. <[EMAIL PROTECTED]> wrote:

> If you aren't already, I recommend putting to use a JS library with Ajax
> support.
> Nothing else, they can reduce the browser compatibility overhead coding
> you'll need to do.
>
> You can pick any of many, but I'm more familiar with Prototype:
> http://prototypejs.org/
>
> ## credits.php
> --------------------
> <?php
> /* ... */  // determine value for $credits
> print min($credits, 0);
> ?>
>
> ## credits.html
> ---------------------
> <html>
>  <body>
>    <div id="credits">Checking credits...</div>
>
>    <script src="prototype.js"></script>
>    <script type="text/javascript">
>    /*** Reference ***/
>    //// http://prototypejs.org/api/periodicalExecuter
>    //// http://prototypejs.org/api/ajax/request
>    //// http://prototypejs.org/api/element/observe
>
>    function creditsCheck(pe) {
>      new Ajax.Request('foobar.php', {
>        method: 'get',
>        parameters: {ts: (new Date()).getTime()}, // cache prevention
>        onSuccess: function (transport) {
>          var elem = $('credits');
>          if (Number(transport.responseText) > 0) {
>            elem.update('Credits remaining: ' + transport.responseText);
>          } else {
>            elem.update('Credits have expired.').setStyle({background:
> '#f00'});
>            pe.stop();
>          }
>        },
>        onFailure: function () {
>          $('credits').update('Could not determine
> credits.').setStyle({background: '#f00'});
>        }
>      });
>    }
>
>    document.observe('dom:loaded', function () {
>      var pe = new PeriodicalExecuter(creditsCheck, 60);
>      creditsCheck(pe); // first check
>    });
>    </script>
>  </body>
> </html>
>
> - Jon L.
>
> On Fri, May 2, 2008 at 4:13 AM, Heysem KAYA <[EMAIL PROTECTED]>
> wrote:
>
> > Hi,
> >
> > I would like to check each minute whether the user credit is finished
> and
> > update the relevant place on page. So I have downloaded however was not
> > able
> > to run some sample ajax code.
> >
> > Is there anyone who has such a simple code to implement?
> >
> >
> >
> > Thanks,
> >
> >
> >
> > Heysem Kaya
> >
> >
>

jQuery library also can do AJAX thing in relatively simple way. check
jquery.com

--- End Message ---
--- Begin Message ---
On Fri, May 2, 2008 at 4:42 AM, Nitsan Bin-Nun <[EMAIL PROTECTED]> wrote:

> umm sorry for interupting but.... RTFM / STFM?
>
> btw, if you dont need history you can write an webby irc client
>
>
> On 01/05/2008, paragasu <[EMAIL PROTECTED]> wrote:
> >
> > > you build one. Thats the point of it wasn't it eh?
> > > A friend and I made a chat with jabber throught second life (the game)
> > and
> > > a
> > > php webpage.
> >
> >
> > interesting. i really wan't to try out your chat implementation. may i?
> > i don't know how to integrate php with jabber since *i don't have much
> > understanding
> > *on how jabber works.. :).. may give me some idea..
> >
>
wow.. good idea. i  overlook this option.  actually, irc server is a good
option..  tq

--- End Message ---
--- Begin Message ---
glad my posts are useful ;)
anyway, you can register a channel on any server, so you dont have actually
to run one by yourself, there are zillions of networks out there that are
just waiting for you. you can also check pjirc, it is a jave applet for
online irc chat, its pretty integrate-able, you can change the background
and the whole look to feat your website, also the language, even Hebrew is
supported :D

HTH,
Nitsan

On 03/05/2008, paragasu <[EMAIL PROTECTED]> wrote:
>
>
>
>  On Fri, May 2, 2008 at 4:42 AM, Nitsan Bin-Nun <[EMAIL PROTECTED]>
> wrote:
>
> > umm sorry for interupting but.... RTFM / STFM?
> >
> > btw, if you dont need history you can write an webby irc client
> >
> >
> >   On 01/05/2008, paragasu <[EMAIL PROTECTED]> wrote:
> > >
> > > > you build one. Thats the point of it wasn't it eh?
> > > > A friend and I made a chat with jabber throught second life (the
> > > game) and
> > > > a
> > > > php webpage.
> > >
> > >
> > > interesting. i really wan't to try out your chat implementation. may
> > > i?
> > > i don't know how to integrate php with jabber since *i don't have much
> > > understanding
> > > *on how jabber works.. :).. may give me some idea..
> > >
> >
> wow.. good idea. i  overlook this option.  actually, irc server is a good
> option..  tq
>
>
>

--- End Message ---
--- Begin Message --- Are there any examples of creating a dll that can be placed in the dll directory of php that can be accessed by php? My language would be Delphi, however an example in C would suffice.

Many thanks...

Todd

--- End Message ---
--- Begin Message ---
Todd Cary wrote:
Are there any examples of creating a dll that can be placed in the dll directory of php that can be accessed by php? My language would be Delphi, however an example in C would suffice.

Many thanks...

Todd
Sorry about my typo in the Subject!

Todd

--- End Message ---
--- Begin Message ---
2008/5/3 Todd Cary <[EMAIL PROTECTED]>:
> Are there any examples of creating a dll that can be placed in the dll
> directory of php that can be accessed by php?  My language would be Delphi,
> however an example in C would suffice.

Custom PHP extensions. I don't know of any Delphi-specific examples,
but this link might give you a starting point:

http://uk.php.net/manual/en/internals2.php

--- End Message ---
--- Begin Message ---
I have this line of code:

$q = "This is the string that will go into the query:
{${mysql_real_escape_string($_GET['searchstring'])}}";

What happens then is the user supplies 'foo' as the search string, and I get
a debug notice "Undefined variable: foo". Why is it treating the value as an
identifier and how do I make it do what I actually want it to do? This is on
PHP5, latest release.



--- End Message ---
--- Begin Message ---
On 5/3/08, cyaugin <[EMAIL PROTECTED]> wrote:
> I have this line of code:
>
>  $q = "This is the string that will go into the query:
>  {${mysql_real_escape_string($_GET['searchstring'])}}";
>
>  What happens then is the user supplies 'foo' as the search string, and I get
>  a debug notice "Undefined variable: foo". Why is it treating the value as an
>  identifier and how do I make it do what I actually want it to do? This is on
>  PHP5, latest release.
>
>
>
>
>  --
>  PHP General Mailing List (http://www.php.net/)
>  To unsubscribe, visit: http://www.php.net/unsub.php
>
>
$q = "This is the string that will go into the query: " .
mysql_real_escape_string($_GET['searchstring']);

-- 
-Casey

--- End Message ---
--- Begin Message ---
Why exactly are you doing this? While variable-variables can be of use
at times, I don't think this is one of them. How do you use this newly
created variable.

- Craige

On Sat, May 3, 2008 at 1:20 PM, cyaugin <[EMAIL PROTECTED]> wrote:
> I have this line of code:
>
>  $q = "This is the string that will go into the query:
>  {${mysql_real_escape_string($_GET['searchstring'])}}";
>
>  What happens then is the user supplies 'foo' as the search string, and I get
>  a debug notice "Undefined variable: foo". Why is it treating the value as an
>  identifier and how do I make it do what I actually want it to do? This is on
>  PHP5, latest release.
>
>
>
>  --
>  PHP General Mailing List (http://www.php.net/)
>  To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
-----Original Message-----
From: cyaugin [mailto:[EMAIL PROTECTED] 
Sent: Saturday, May 03, 2008 10:20 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Complex escape string

I have this line of code:

$q = "This is the string that will go into the query:
{${mysql_real_escape_string($_GET['searchstring'])}}";

What happens then is the user supplies 'foo' as the search string, and I get
a debug notice "Undefined variable: foo". Why is it treating the value as an
identifier and how do I make it do what I actually want it to do? This is on
PHP5, latest release.




---------------

It looks to me like what is happening is this piece:
${mysql_real_escape_string($_GET['searchstring'])}

Gets collapsed to $foo when mysql_real_escape_string($_GET['searchstring'])
== 'foo'. ${'a'} will expand to $a. I think that your problem is that you
need to drop that '$' before the brace around the function call.





--- End Message ---
--- Begin Message ---
I have a quick question on what's coming in PHP 6.

I've incorporated use of the ability to call instance methods through static calls, allowing for me to mimic multiple inheritance without having to make edits to classes that are already working because of the behavior of '$this' when instance methods are called statically.

As stated on in the basics section on classes and objects:

"$this is a reference to the calling object (usually the object to which the method belongs, but can be another object, if the method is called statically from the context of a secondary object)."

I've made great use of that functionality in my framework. However, It sounds like this is going to cause a fatal error in PHP6. Is this in fact true? And, if the behavior is going to change, can somebody explain what the impetus for this change was?

Thank you very much for your time,

Adam

Adam Richardson
Envision Internet Consulting, LLC
Phone: (517)623-0485

Services and insight for building effective, user-oriented websites.




--- End Message ---
--- Begin Message --- I've incorporated use of the ability to call instance methods through static calls, allowing for me to mimic multiple inheritance without having to make edits to classes that are already working because of the behavior of '$this' when instance methods are called statically.

As stated on in the basics section on classes and objects:

"$this is a reference to the calling object (usually the object to which the method belongs, but can be another object, if the method is called statically from the context of a secondary object)."

I've made great use of that functionality in my framework. However, It sounds like this is going to cause a fatal error in PHP6. Is this in fact true? And, if the behavior is going to change, can somebody explain what the impetus for this change was?

Thank you very much for your time,

Adam

Adam Richardson
Envision Internet Consulting, LLC
Phone: (517)623-0485

Services and insight for building effective, user-oriented websites.




--- End Message ---
--- Begin Message ---
I am trying to load PHP objects stored in a database, where the class
name is stored in a column:

$object = new $resultSet->getString(1);

This fails for the same reason that the following fails:

<?php

class Foo
{
  public function className()
  {
    return 'Foo';
  }
}

$foo = new Foo;
$bar = new $foo->className();

Fatal error: Class name must be a valid object or a string in test.php
on line 12

I guess this error is due to the confusion of parsing "()" as the
argument list for the "className" function, or the "Foo" constructor...

I work around this error by using a temp variable:

$tmp = $foo->className(); $bar = new $tmp;

- however the above reads like hacky code : (

When calling dynamically named functions, I generally use
call_user_func() to avoid awkwardness with $object->$tmp($arg1, ...)

In other words, I prefer:

call_user_func(array($object, 'get'.$someName), $arg1, ...);

- to:

$tmp = 'get'.$someName; $object->$tmp($arg1, ...);

However there does not appear to be an analog of call_user_func() for
constructing new instances of dynamically named classes?

If I recall correctly, there was also a way to work around calling
dynamically named functions (e.g. $object->$tmp($arg1, ...);) using
curly braces:

$object->{'get'.$someName}($arg1, ...);

- however I cannot recall the exact syntax.

Can anyone confirm that there is a curly brace syntax for calling
dynamically named functions? Could it be applied to instantiating
dynamically named classes?

Can anyone recommend a cleaner alternative to:

$tmp = $foo->className(); $bar = new $tmp;

Thanks and best wishes, Jack


--- End Message ---

Reply via email to