OSEC

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 4 May 2008 15:13:02 -0000 Issue 5440

php-general-digest-helplists.php.net
Date: Sun May 04 2008 - 10:13:02 CDT


php-general Digest 4 May 2008 15:13:02 -0000 Issue 5440

Topics (messages 273848 through 273855):

Re: new $foo->className(); Class name must be a valid object or a string
        273848 by: Stut
        273850 by: Casey

Re: web based chat app
        273849 by: paragasu
        273854 by: Richard Heyes

Execute command from web browser
        273851 by: opc.orenses.com
        273852 by: Casey

Re: Question on PHP 6 and static calls to instance methods.
        273853 by: Robert Cummings

Web page excerpt editor
        273855 by: Mike Potter

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

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

attached mail follows:


On 4 May 2008, at 00:46, Jack Bates wrote:
> 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();

I would rather have a factory method that returns a new instance of
the class. There's no need for the outside world to know the class name.

<?php
   class Foo
   {
     public function newInstance()
     {
       return new self();
     }

     public function test($a)
     {
       echo 'test: '.$a."\n";
     }
   }

   $foo = new Foo;
   $foo->test('foo');
   $bar = $foo->newInstance();
   $bar->test('bar');
?>

However, if you insist on doing it your way can I make a small
suggestion? It's better to spend your time on functionality rather
than finding ways to save some typing. I see no reason to try to
combine the two statements - saving typing and a pitiful amount of
disk space are the only benefits.

-Stut

--
http://stut.net/

attached mail follows:


On May 3, 2008, at 4:46 PM, Jack Bates <ms419freezone.co.uk> wrote:

> 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
>
Does...
<?php
  $bar = new $foo->className()();
?>
...work?

Otherwise, I'd just do...
<?php
  $className = $foo->className();
  $bar = new $className;
?>
...instead of $tmp.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

attached mail follows:


On Sun, May 4, 2008 at 5:37 AM, Nitsan Bin-Nun <nitsanbngmail.com> wrote:

> 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
>
>

i did try to find opensource php + AJAX base IRC client. but found none.
but there is a PEAR library available to connect to IRC server. i will look
into it
and try to write some IRC client. it gonna be fun ;)

attached mail follows:


> i did try to find opensource php + AJAX base IRC client. but found none.
> but there is a PEAR library available to connect to IRC server. i will look
> into it
> and try to write some IRC client. it gonna be fun ;)

Not having read the rest of the thread, I got mildly interested in this
and made a simple web based chat thing. You can try it out with seperate
browsers (simulating different clients). From what I remember it
probably won't cope with the load you're refering to, but it's just an
example (oh and (for better or worse) there's no need for an IRC server).

http://www.phpguru.org/chat/chat.php

--
Richard Heyes

+----------------------------------------+
| Access SSH with a Windows mapped drive |
| http://www.phpguru.org/sftpdrive |
+----------------------------------------+

attached mail follows:


Hi all

I try write a code to execute service in my server from web browser

I write next

/var/www/html/squidup.html
<?
exec ('/usr/bin/squid/sbin/squid')
echo "Squid UP"
?>

but, don't work from web browser.

What is wrong

Thanks,

attached mail follows:


On 5/3/08, opcorenses.com <opcorenses.com> wrote:
>
> Hi all
>
>
> I try write a code to execute service in my server from web browser
>
> I write next
>
> /var/www/html/squidup.html
Should it be... squidup.php?
> <?
> exec ('/usr/bin/squid/sbin/squid')
> echo "Squid UP"
> ?>
>
> but, don't work from web browser.
>
> What is wrong
>
> Thanks,
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
-Casey

attached mail follows:


You would have better luck posing this question to the internals list:

    internalslists.php.net

Cheers,
Rob.

On Sat, 2008-05-03 at 17:32 -0400, Adam Richardson wrote:
> 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.
>
>
>
--
http://www.interjinn.com
Application and Templating Framework for PHP

attached mail follows:


We are looking for a script similar to SnippetMaster
(http://www.snippetmaster.com/). We want to give the non-html-coding
client the ability to make edits to one part of one page on their Web
site on a weekly or near-daily basis. We are looking for something
free and turnkey, so we can move on to the next paying client. As
stated, the client is not html-aware so SnippetMaster itself fails our
criteria, the free version does not offer WYSIWYG previews of changes
while editing (http://www.snippetmaster.com/compare.html).

Does anyone have any experience with something else? Alternately, has
anyone written something they'd be willing to share under GPL?

Ski