[PHP] PHP5 OOP: Abstract classes, multiple inheritance and constructors
Example/working code here: https://gist.github.com/mhulse/5833826 Couple questions: 1. Is there anything wrong with the way I'm using the abstract class? If so, how could I improve the logic/setup? 2. Is there a way for me to pass $foo to the parent class, from the child, without having to ferry that variable through the abstract class? In other words, is there such a thing as: parent::parent::__construct($foo); ... I want to have my abstract class constructor do things, yet I'd like to avoid having to repeat myself for when it comes to passing constructor arguments from the child. Any tips would be appreciated. Sorry if silly questions. Thanks! Micky -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php5-fpm segfault
Hi : could you file a bug at https://bugs.php.net/ this is the proper way to report a bug :) thanks -- Laruence Xinchen Hui http://www.laruence.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php5-fpm segfault
You think this is PHP's bug? I'm not sure. Because PHP installed not latest version and yesterday i tune memory_limit setting to 256M (was -1) and no segfaults registered since that moment. I think, bad designed script allocate too much memory and php-fpm worker become mad and kill himself. But it's hard to find the culprit in a huge number of scripts. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP5 cgi Suexec htaccess rewrite issue
I am running a server with cPanel on and want to have php run as a cgi with Suexec enabled I cannot seem to rectify an issue, when I set the handler to cgi, my rewrite rules on one of my sites stop working Sample url: http://examplesite.com/ad/123-abcde/ The rewrite rule for this is below; RewriteEngine on RewriteBase / RewriteRule ^ad/([0-9]+)(.*)$ ./index.php/ads/ads/action/viewAd/frmAdsID/$1/adTitle/$2 [L] Currently the php 5 handler is dso, and the rewrite rule works perfectly. If the handler is set to cgi, the rewrite rule does not work and I the site just displays the home page. I am at a loss and would appreciate some help. Thanks in advance!
Re: [PHP] PHP5 cgi Suexec htaccess rewrite issue
On Thu, Sep 29, 2011 at 5:43 AM, Shaun Morrow morrow.sh...@gmail.comwrote: I am running a server with cPanel on and want to have php run as a cgi with Suexec enabled I cannot seem to rectify an issue, when I set the handler to cgi, my rewrite rules on one of my sites stop working Sample url: http://examplesite.com/ad/123-abcde/ The rewrite rule for this is below; RewriteEngine on RewriteBase / RewriteRule ^ad/([0-9]+)(.*)$ ./index.php/ads/ads/action/viewAd/frmAdsID/$1/adTitle/$2 [L] Currently the php 5 handler is dso, and the rewrite rule works perfectly. If the handler is set to cgi, the rewrite rule does not work and I the site just displays the home page. I am at a loss and would appreciate some help. Thanks in advance! Did you make the changes accordingly in php.ini? I recall that cgi/fastcgi requires different configuration than from isapi type - dll/dso. I don't know how httpd handles impersonation on *nix platform as I've never had to configure it that way. Here's a few from the php.ini ; The root of the PHP pages, used only if nonempty. ; if PHP was not compiled with FORCE_REDIRECT, you SHOULD set doc_root ; if you are running php as a CGI under any web server (other than IIS) ; see documentation for security issues. The alternate is to use the ; cgi.force_redirect configuration below ; http://php.net/doc-root ; cgi.force_redirect is necessary to provide security running PHP as a CGI under ; most web servers. Left undefined, PHP turns this on by default. You can ; turn it off here AT YOUR OWN RISK ; **You CAN safely turn this off for IIS, in fact, you MUST.** ; http://php.net/cgi.force-redirect ; if cgi.nph is enabled it will force cgi to always sent Status: 200 with ; every request. PHP's default behavior is to disable this feature. ; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI. PHP's ; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok ; what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting ; this to 1 will cause PHP CGI to fix its paths to conform to the spec. A setting ; of zero causes PHP to behave as before. Default is 1. You should fix your scripts ; to use SCRIPT_FILENAME rather than PATH_TRANSLATED. ; http://php.net/cgi.fix-pathinfo ; FastCGI under IIS (on WINNT based OS) supports the ability to impersonate ; security tokens of the calling client. This allows IIS to define the ; security context that the request runs under. mod_fastcgi under Apache ; does not currently support this feature (03/17/2002) ; Set to 1 if running under IIS. Default is zero. ; http://php.net/fastcgi.impersonate Note that the above is from old config file and is configured for PHP to run as FastCGI on IIS7.5. There maybe recent changes regarding httpd and impersonation. Go through the php.ini and make all relevant changes regarding 'cgi'. Regards, Tommy
[PHP] php5-fpm segfault
Hello. I'm getting problem. OS: Ububtu Server 2.6.38-8-server PHP: PHP 5.3.5-1ubuntu7.2 with Suhosin-Patch Work over fastcgi (fpm) with cherokee web server. PHP fall often with such messages in syslog: Sep 28 11:01:25 userver kernel: [278665.292418] php5-fpm[31892]: segfault at 80001000321 ip 0069f427 sp 7fffddf571b0 error 4 in php5-fpm[40+755000] I took core dump and gdb it: root@userver:~# gdb /usr/sbin/php5-fpm /tmp/core-php5-fpm.8289 ... gnu gpl banner omitted... Reading symbols from /usr/sbin/php5-fpm...Reading symbols from /usr/lib/debug/usr/sbin/php5-fpm...done. done. [New Thread 8289] warning: Can't read pathname for load map: Input/output error. Reading symbols from /lib/x86_64-linux-gnu/libcrypt.so.1...(no debugging symbols found)...done. ... a lot of loading symbols messages omitted ... Core was generated by `php-fpm: pool www '. Program terminated with signal 11, Segmentation fault. #0 zend_hash_destroy (ht=0x80001000301) at /build/buildd/php5-5.3.5/Zend/zend_hash.c:723 723 HASH_PROTECT_RECURSION(ht); (gdb) bt #0 zend_hash_destroy (ht=0x80001000301) at /build/buildd/php5-5.3.5/Zend/zend_hash.c:723 #1 0x007293c1 in fcgi_close (req=0x7fff6a7783e0, force=0, destroy=1) at /build/buildd/php5-5.3.5/sapi/fpm/fpm/fastcgi.c:675 #2 0x00729d3d in fcgi_finish_request (req=0x7fff6a7783e0, force_close=0) at /build/buildd/php5-5.3.5/sapi/fpm/fpm/fastcgi.c:1000 #3 0x0072f036 in sapi_cgi_deactivate () at /build/buildd/php5-5.3.5/sapi/fpm/fpm/fpm_main.c:886 #4 0x006477ed in sapi_deactivate () at /build/buildd/php5-5.3.5/main/SAPI.c:444 #5 0x0063efe5 in php_request_shutdown (dummy=0x80001000301) at /build/buildd/php5-5.3.5/main/main.c:1658 #6 0x00730642 in main (argc=46077184, argv=0xdddb60) at /build/buildd/php5-5.3.5/sapi/fpm/fpm/fpm_main.c:1902 (gdb) print ht $1 = (HashTable *) 0x80001000301 (gdb) print *ht Cannot access memory at address 0x80001000301 Please, tell what the problem is? How to find out which script causing this problem? Or this is not scripting problem? Yes, this is not latest php version and there are some problems with update. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php5 - website development - what next
Hi All, I am PHP 4 PHP 5 developer for last 6 yrs. Last year also got Zend certification. Since now I have work on different CMS, Social Networking, telecome , horse racing domains. But now I am little bored with developing website. What other things I can do with PHP ? Even I believe my knowledge, interest, market value with PHP 5 is getting saturated. Do you guys suggest me what other thing I can learn or work which help me to keep my lust for PHP alive and also boost my career. Regards Rakesh
Re: [PHP] php5 - website development - what next
On Fri, Oct 8, 2010 at 09:53, Rakesh Mishra rakesh.mis...@gmail.com wrote: Even I believe my knowledge, interest, market value with PHP 5 is getting saturated. Do you guys suggest me what other thing I can learn or work which help me to keep my lust for PHP alive and also boost my career. Write desktop applications: http://gtk.php.net/ . -- /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
Re: [PHP] php5 - website development - what next
On 10/08/2010 22:06, 惠新宸 wrote: test, i can't send mail to lists? thanks On 10/08/2010 22:02, 惠新宸 wrote: Hi: 1. you can be a Software Architect 2. you can abstract common requirements, developed php extension. thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php5 - website development - what next
On Fri, Oct 08, 2010 at 07:23:59PM +0530, Rakesh Mishra wrote: Hi All, I am PHP 4 PHP 5 developer for last 6 yrs. Last year also got Zend certification. Since now I have work on different CMS, Social Networking, telecome , horse racing domains. But now I am little bored with developing website. What other things I can do with PHP ? Even I believe my knowledge, interest, market value with PHP 5 is getting saturated. Do you guys suggest me what other thing I can learn or work which help me to keep my lust for PHP alive and also boost my career. There are a variety of major projects which use PHP as their primary language. Like WordPress. See freshmeat.net and sourceforge.net for projects written in PHP. You could contribute to these projects, and increase your knowledge and prestige. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php5 - website development - what next
On 8 October 2010 14:53, Rakesh Mishra rakesh.mis...@gmail.com wrote: Hi All, I am PHP 4 PHP 5 developer for last 6 yrs. Last year also got Zend certification. Since now I have work on different CMS, Social Networking, telecome , horse racing domains. But now I am little bored with developing website. What other things I can do with PHP ? Even I believe my knowledge, interest, market value with PHP 5 is getting saturated. Do you guys suggest me what other thing I can learn or work which help me to keep my lust for PHP alive and also boost my career. Regards Rakesh I'm building Windows Services (not Web Services) with PHP and an enhanced pecl/win32service extension, in conjunction with WScript.Shell to simulate threading and and WinCache for inter-processing comms. OK. It is a daft thing to do. But it is working and is replacing a bunch of console apps written in .BAT with some .EXEs. The SysOps are happier as it is just a normal windows services (so they can stop/start/pause it). Shutdown/bootup server - all OK. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP5+APACHE 2.2 + Windows 2003 production server
Hi all PHP manual state We do not recommend using a threaded MPM in production with Apache 2. Use the prefork MPM instead, or use Apache 1. For information on why, read the related FAQ entry on using Apache2 with a threaded MPM ( http://www.php.net/manual/en/install.windows.apache2.php ) From apache.org the compiled exe you can download it seems compiled against threaded MPM. Even the all-in-one packages like WAMPSERVER (http://www.wampserver.com/en/) or XAMPP Light install PHP as Apache module on threaded MPM Apache So I'm wondering, is the manual outdated, or should I consider other configuration to install on my production servers? Thank you Darvin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP5 SOAP...
I'm working on a project using SOAP and WS-Security in which I am failing miserably. Is there a way to inspect the actual XML, header, etc. that is actually being sent. I feel like I am constructing the call correctly, and I know exactly what needs to be sent, but I dont know how to see exactly what is sent - all I get back are useless errors like not enough information sent, etc... Any ideas? Any SOAP pros out there? Russell Jones CTO Virante, Inc. r...@virante.com 919-459-1035
RE: [PHP] PHP5 SOAP...
hi russell... isn't the actual soap data/packet that's being sent over the wire viewable via an app like livehttpheaders... (at least from firefox) or are you looking for something in much more detail... -Original Message- From: rjon...@gmail.com [mailto:rjon...@gmail.com]on Behalf Of Russell Jones Sent: Tuesday, June 16, 2009 8:22 AM To: PHP General Subject: [PHP] PHP5 SOAP... I'm working on a project using SOAP and WS-Security in which I am failing miserably. Is there a way to inspect the actual XML, header, etc. that is actually being sent. I feel like I am constructing the call correctly, and I know exactly what needs to be sent, but I dont know how to see exactly what is sent - all I get back are useless errors like not enough information sent, etc... Any ideas? Any SOAP pros out there? Russell Jones CTO Virante, Inc. r...@virante.com 919-459-1035 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 SOAP...
Hi, Wednesday, June 17, 2009, 1:21:47 AM, you wrote: RJ I'm working on a project using SOAP and WS-Security in which I am failing RJ miserably. RJ Is there a way to inspect the actual XML, header, etc. that is actually RJ being sent. I feel like I am constructing the call correctly, and I know RJ exactly what needs to be sent, but I dont know how to see exactly what is RJ sent - all I get back are useless errors like not enough information sent, RJ etc... RJ Any ideas? Any SOAP pros out there? RJ Russell Jones RJ CTO Virante, Inc. RJ r...@virante.com RJ 919-459-1035 Not a pro but... Try something like this: //object to pass function variables class requestObject { function requestObject($list) { foreach($list as $key=$val) $this-$key = $val; } } $client = new SoapClient(wsdl.xml, array('login'= login, 'password'= password, 'trace'=true)); $soapstruct = new requestObject(array('clientId'=12342, 'leagueId'=0)); //use whatever variables are needed try { $info = $client-soapFunction($soapstruct); echo REQUEST:\n . $client-__getLastRequest() . br /\n; print_r($info); } catch (SoapFault $e) { echo SOAP Fault: .$e-getMessage().br /\n; echo REQUEST:\n . $client-__getLastRequest() . br /\n; } -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP5 based Web-Chat?
Hello, I like to install a forum for my customers and additional a PHP5 based Web-Chat system with publich and private chatrooms. What can you recommend? Thanks, Greetings and nice Day/Evening Michelle Konzack Systemadministrator Tamay Dogan Network Debian GNU/Linux Consultant -- Linux-User #280138 with the Linux Counter, http://counter.li.org/ # Debian GNU/Linux Consultant # http://www.tamay-dogan.net/ Michelle Konzack http://www.can4linux.org/ Apt. 917 http://www.flexray4linux.org/ 50, rue de Soultz Jabber linux4miche...@jabber.ccc.de 67100 Strasbourg/France IRC #Debian (irc.icq.com) Tel. DE: +49 177 9351947 ICQ #328449886Tel. FR: +33 6 61925193 signature.pgp Description: Digital signature
[PHP] php5-mhash disabled...
I just saw that mhash is disabled in the spec file for php5 if SUSE version is 11.0 or higher. Simple question, does it do any harm? I know it's been deprecated in favor for hash, but I have quite a few apps using mhash still, so if it doesn't do any harm I thought I'd continue using it until all apps has been remade for hash. I really didn't find any relevant info on it with a quick Google search, so I ask you fellows. Thanks, Anders. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php5-mhash disabled...
Anders Norrbring wrote: I just saw that mhash is disabled in the spec file for php5 if SUSE version is 11.0 or higher. Simple question, does it do any harm? If they decided to do that it's best to ask suse (or on the opensuse lists if you're using that flavour). It may just be because it's deprecated but it could be for some other reason (eg binary compatibility issues or licensing issues or .. ). -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP5 - SOAP extension and WSDL generation
Hi there, I'm trying to find out how to generate a WSDL with the functions I am providing as web services, and I'm finding various posts on the net that say it's not possible with the SOAP extension built in PHP5. At the same time, I find that http://www.php.net/manual/en/soap.constants.php lists four constants that have to do with WSDL caching: WSDL_CACHE_NONE (integer) WSDL_CACHE_DISK (integer) WSDL_CACHE_MEMORY (integer) WSDL_CACHE_BOTH (integer) which apparently are only used in the http://www.php.net/manual/en/soapserver.soapserver.php method. so I'm a bit confused about the lack of info there. Why would the extension not include a WSDL-generation method for one given server object while other libraries (NuSOAP and PEAR::SOAP) do? Isn't that kind of pushing users away from the core extension? I mean, generating a WSDL is not a funny job, but many services will need one and a developer doesn't want to be updating his at every change he makes in his service function, does he? Thank you, Yannick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php5 with apache 1.x - white page
Hi there, after strugling a while with the installation of php5 on an older suse system with mysql 3.x and apache 1.x I got it compiled and installed. Apache starts and there are processes running, even the access log shows access to it. Response is 500 (internal error). The page itself does not load and it shows only a white page. I can not find any entry inside a log that show unnormal hints. Any idea where I could look for the error? I tried php error log file and var/log/messages. Thank you for any help. Merlin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP5 DOM Problem
Hi there. I don't kno id this is the correct place to post but... I am using the PHP5 DOM to make up RSS Feeds .. A Problem I have is I want to make this up for itunes.. ?xml version=1.0 encoding=UTF-8? rss version=2.00 xmlns:itunes=http://www.itunes.com/dtds/podcast-1.0.dtd; etc.. I use.. $p_dom = new DOMDocument('1.0','UTF-8'); $p_rss = $p_dom-createElement('rss'); $p_rss-setAttribute('version', '2.00'); $p_rss-setAttribute('xmlns:itunes','http://www.itunes.com/dtds/podcast-1.0.dtd'); $p_dom-appendChild($p_rss); which is working for me.. Debian (PHP 5.2.6-2+b1) but doesn't work on some other people with other versions of php5 ( I don't know yet which version they have) they only get ?xml version=1.0 encoding=UTF-8? rss version=2.00 So the name space is missing.. So I looked up http://nz2.php.net/manual/en/domelement.setattribute.php and it says the correct way is to use createElementNS.. but I have tried and tried and I cannot get it to make up what I want it to do. can someone help? I also want to make something like ?xml version=1.0 encoding=UTF-8? rss version=0.91 xmlns:media=http://search.yahoo.com/mrss/; xmlns:dcterms=http://purl.org/dc/terms/; xmlns:gm=http://www.google.com/schemas/gm/1.1; xmlns:av=http://www.searchvideo.com/schemas/av/1.0; xmlns:dc=http://purl.org/dc/elements/1.1/; for mediarss feeds + other types . but I can't seem to be able to use CreateElementNS to make this up either Can someone help?? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 and the DOM model
On Thu, Apr 17, 2008 at 10:05:11AM +0200, Michael Preminger wrote: Hello! Seems that PHP gets more and more object oriented, which is good. I am now running a course in PHP, using PHP 5, where we are going to use the *DOM* interface. I am trying to teach them good OO practices, meaning that we insistently hide properties and expose them as get or set methods. Get/set methods are more often than not breaking encapsulation and should be avoided (unless purposefully designing Model object or something similar.) Looking at the PHPs *DOM* implementation, I see that many of the properties are exposed directly, without even offering get methods. Can you please provide an example of where this is happening? 1. Is there something I am misunderstanding orotherwise missing? (I havenot used *DOM* in PHP before). 2.This poses a pedagogical problem for me as a teacher. How do I explain this contradiction to my students? Explain that the DOM API and PHP's binding to the DOM API are 2 different things with 2 different goals. Thanks Michael -- 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
Re: [PHP] PHP5 and the DOM model
On Thu, Apr 17, 2008 at 5:43 PM, Nick Stinemates [EMAIL PROTECTED] wrote: On Thu, Apr 17, 2008 at 10:05:11AM +0200, Michael Preminger wrote: Hello! Seems that PHP gets more and more object oriented, which is good. I am now running a course in PHP, using PHP 5, where we are going to use the *DOM* interface. I am trying to teach them good OO practices, meaning that we insistently hide properties and expose them as get or set methods. Get/set methods are more often than not breaking encapsulation and should be avoided (unless purposefully designing Model object or something similar.) egh? we had a massive argument about this last year, but if u ask me data hiding is an integral part of encapsulation; therefore i agree w/ Michael. Looking at the PHPs *DOM* implementation, I see that many of the properties are exposed directly, without even offering get methods. so, if its a big deal, write a proxy(s) which adds the encapsulation (as u see it) u need. Can you please provide an example of where this is happening? heres a list of em from DomDocument, readonly public string $actualEncodinghttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.actualencoding; readonly public DOMConfiguration $confighttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.config; readonly public DOMDocumentTypehttp://us2.php.net/manual/en/class.domdocumenttype.php $doctypehttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.doctype; readonly public DOMElementhttp://us2.php.net/manual/en/class.domelement.php $documentElementhttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.documentelement; public string $documentURIhttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.documenturi; public string $encodinghttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.encoding; public bool $formatOutputhttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.formatoutput; readonly public DOMImplementationhttp://us2.php.net/manual/en/class.domimplementation.php $implementationhttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.implementation; public bool $preserveWhiteSpacehttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.preservewhitespace =true ; public bool $recoverhttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.recover; public bool $resolveExternalshttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.resolveexternals; public bool $standalonehttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.standalone; public bool $strictErrorCheckinghttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.stricterrorchecking =true ; public bool $substituteEntitieshttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.substituteentities; public bool $validateOnParsehttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.validateonparse =false ; public string $versionhttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.version; readonly public string $xmlEncodinghttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.xmlencoding; public bool $xmlStandalonehttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.xmlstandalone; public string $xmlVersionhttp://us2.php.net/manual/en/class.domdocument.php#domdocument.props.xmlversion; 1. Is there something I am misunderstanding orotherwise missing? (I havenot used *DOM* in PHP before). have you looked at SimpleXMLElement / SimpleXMLIterator ?? i find it to be one of those 80% / 20% relationships where simplexml takes care of the needs most of the time (and saves your poor brain from smoking). 2.This poses a pedagogical problem for me as a teacher. How do I explain this contradiction to my students? the world doest operate 'by-the-book' thats life. i was a teacher once (just for a semester) but i was teaching oop. at the end of the day who knows why they did it that way. perhaps their views are different than yours or the book from which your teaching. explain to them that there are options, such as building a proxy, but there will be consequences in terms of performance and increased complexity. -nathan
Re: [PHP] PHP5 and the DOM model
On Fri, Apr 18, 2008 at 10:25:29AM -0600, Nathan Nobbe wrote: On Thu, Apr 17, 2008 at 5:43 PM, Nick Stinemates [EMAIL PROTECTED] wrote: On Thu, Apr 17, 2008 at 10:05:11AM +0200, Michael Preminger wrote: Hello! Seems that PHP gets more and more object oriented, which is good. I am now running a course in PHP, using PHP 5, where we are going to use the *DOM* interface. I am trying to teach them good OO practices, meaning that we insistently hide properties and expose them as get or set methods. Get/set methods are more often than not breaking encapsulation and should be avoided (unless purposefully designing Model object or something similar.) egh? we had a massive argument about this last year, but if u ask me data hiding is an integral part of encapsulation; therefore i agree w/ Michael. Data Hiding IS Encapsulation. But, you have to agree, ?php class Lol { private $bar; public function getBar() { return $bar } public function setBar($bar) { $this-bar = $bar} } ? Is no different than: ?php class Lol { public $bar; } ? Here's a more thought out argument from http://www.javaworld.com/javaworld/jw-09-2003/jw-0905-toolbox.html : A fundamental precept of OO systems is that an object should not expose any of its implementation details. This way, you can change the implementation without changing the code that uses the object. It follows then that in OO systems you should avoid getter and setter functions since they mostly provide access to implementation details. To see why, consider that there might be 1,000 calls to a getX() method in your program, and each call assumes that the return value is of a particular type. You might store getX()'s return value in a local variable, for example, and that variable type must match the return-value type. If you need to change the way the object is implemented in such a way that the type of X changes, you're in deep trouble. -- Nick Stinemates ([EMAIL PROTECTED]) http://nick.stinemates.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 and the DOM model
Nick Stinemates wrote: On Fri, Apr 18, 2008 at 10:25:29AM -0600, Nathan Nobbe wrote: On Thu, Apr 17, 2008 at 5:43 PM, Nick Stinemates [EMAIL PROTECTED] wrote: On Thu, Apr 17, 2008 at 10:05:11AM +0200, Michael Preminger wrote: Hello! Seems that PHP gets more and more object oriented, which is good. I am now running a course in PHP, using PHP 5, where we are going to use the *DOM* interface. I am trying to teach them good OO practices, meaning that we insistently hide properties and expose them as get or set methods. Get/set methods are more often than not breaking encapsulation and should be avoided (unless purposefully designing Model object or something similar.) egh? we had a massive argument about this last year, but if u ask me data hiding is an integral part of encapsulation; therefore i agree w/ Michael. Data Hiding IS Encapsulation. But, you have to agree, ?php class Lol { private $bar; public function getBar() { return $bar } public function setBar($bar) { $this-bar = $bar} } ? Is no different than: ?php class Lol { public $bar; } ? Here's a more thought out argument from http://www.javaworld.com/javaworld/jw-09-2003/jw-0905-toolbox.html : A fundamental precept of OO systems is that an object should not expose any of its implementation details. This way, you can change the implementation without changing the code that uses the object. It follows then that in OO systems you should avoid getter and setter functions since they mostly provide access to implementation details. To see why, consider that there might be 1,000 calls to a getX() method in your program, and each call assumes that the return value is of a particular type. You might store getX()'s return value in a local variable, for example, and that variable type must match the return-value type. If you need to change the way the object is implemented in such a way that the type of X changes, you're in deep trouble. No,but in the first one, you can control, from within the class/method, what data is actually allowed to be injected into that variable. Whereas the second example would allow you to stuff any type of data into that class variable. That might not be a good thing. -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 and the DOM model
Data Hiding IS Encapsulation. But, you have to agree, ?php class Lol { private $bar; public function getBar() { return $bar } public function setBar($bar) { $this-bar = $bar} } ? Is no different than: ?php class Lol { public $bar; } ? Here's a more thought out argument from http://www.javaworld.com/javaworld/jw-09-2003/jw-0905-toolbox.html : A fundamental precept of OO systems is that an object should not expose any of its implementation details. This way, you can change the implementation without changing the code that uses the object. It follows then that in OO systems you should avoid getter and setter functions since they mostly provide access to implementation details. To see why, consider that there might be 1,000 calls to a getX() method in your program, and each call assumes that the return value is of a particular type. You might store getX()'s return value in a local variable, for example, and that variable type must match the return-value type. If you need to change the way the object is implemented in such a way that the type of X changes, you're in deep trouble. No,but in the first one, you can control, from within the class/method, what data is actually allowed to be injected into that variable. Whereas the second example would allow you to stuff any type of data into that class variable. That might not be a good thing. That's a relatively narrow minded response to my point, since I gave a pretty concrete example of exactly what I meant, followed by a great article which furthered my point. The general rule of encapsulation is: Don't ask an object for data, ask the object to work with the data. -- Nick Stinemates ([EMAIL PROTECTED]) http://nick.stinemates.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 and the DOM model
On Fri, Apr 18, 2008 at 11:21 AM, Nick Stinemates [EMAIL PROTECTED] wrote: On Fri, Apr 18, 2008 at 10:25:29AM -0600, Nathan Nobbe wrote: On Thu, Apr 17, 2008 at 5:43 PM, Nick Stinemates [EMAIL PROTECTED] wrote: On Thu, Apr 17, 2008 at 10:05:11AM +0200, Michael Preminger wrote: Hello! Seems that PHP gets more and more object oriented, which is good. I am now running a course in PHP, using PHP 5, where we are going to use the *DOM* interface. I am trying to teach them good OO practices, meaning that we insistently hide properties and expose them as get or set methods. Get/set methods are more often than not breaking encapsulation and should be avoided (unless purposefully designing Model object or something similar.) egh? we had a massive argument about this last year, but if u ask me data hiding is an integral part of encapsulation; therefore i agree w/ Michael. Data Hiding IS Encapsulation. But, you have to agree, ?php class Lol { private $bar; public function getBar() { return $bar } public function setBar($bar) { $this-bar = $bar} } ? Is no different than: ?php class Lol { public $bar; } ? it is different, by your very definition. quote 'Data Hiding IS Encapsulation' so the difference in the 2 examples you supplied is that the first one is an example of encapsulation, whereas the later is not. encapsulation provides control. it reduces the possibility of client code binding to implementation details which decreases coupling. go into the archives, you will find the argument from last year. its in the same one about interfaces, that we pretty much re-hashed this week. -nathan
Re: [PHP] PHP5 and the DOM model
On Fri, Apr 18, 2008 at 11:50 AM, Nick Stinemates [EMAIL PROTECTED] wrote: That's a relatively narrow minded response to my point, since I gave a pretty concrete example of exactly what I meant, no, its a very valid criticism of your flawed example. you supply a definition of encapsulation, and then demonstrate, by example, that you dont understand its importance. followed by a great article which furthered my point. take a look at the books i listed in the argument last year. youll find that all the books ive ever read on oop are strong proponents of data-hiding as a component of encapsulation. The general rule of encapsulation is: Don't ask an object for data, ask the object to work with the data. more precisely, operations on a class should be driven through a well-defined public interface. -nathan
Re: [PHP] PHP5 and the DOM model
Nick Stinemates wrote: Data Hiding IS Encapsulation. But, you have to agree, ?php class Lol { private $bar; public function getBar() { return $bar } public function setBar($bar) { $this-bar = $bar} } ? Is no different than: ?php class Lol { public $bar; } ? Here's a more thought out argument from http://www.javaworld.com/javaworld/jw-09-2003/jw-0905-toolbox.html : A fundamental precept of OO systems is that an object should not expose any of its implementation details. This way, you can change the implementation without changing the code that uses the object. It follows then that in OO systems you should avoid getter and setter functions since they mostly provide access to implementation details. To see why, consider that there might be 1,000 calls to a getX() method in your program, and each call assumes that the return value is of a particular type. You might store getX()'s return value in a local variable, for example, and that variable type must match the return-value type. If you need to change the way the object is implemented in such a way that the type of X changes, you're in deep trouble. No,but in the first one, you can control, from within the class/method, what data is actually allowed to be injected into that variable. Whereas the second example would allow you to stuff any type of data into that class variable. That might not be a good thing. That's a relatively narrow minded response to my point, since I gave a pretty concrete example of exactly what I meant, followed by a great article which furthered my point. Let me quote, you said this: Is no different than You are wrong, in fact it IS different. Having your own custom methods to get or set data allows you to have more control over what data is injected into your object. I would call is a personal preference which may not work for you, but works fine for me. All I can say is that all my __set methods do data sanitizing and validation, which is were I think it should be done. If anybody thinks this might be a bad thing, please by all means explain why it is bad. The general rule of encapsulation is: Don't ask an object for data, ask the object to work with the data. I hope it checks the data first before using it. If you don't then you might end up with something you had not planned on. If I am not to ask an object for data how is my db class/object ever going to return me data from my database? -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 and the DOM model
On Fri, 2008-04-18 at 11:50 -0700, Jim Lucas wrote: Nick Stinemates wrote: Data Hiding IS Encapsulation. But, you have to agree, ?php class Lol { private $bar; public function getBar() { return $bar } public function setBar($bar) { $this-bar = $bar} } ? Is no different than: ?php class Lol { public $bar; } ? Here's a more thought out argument from http://www.javaworld.com/javaworld/jw-09-2003/jw-0905-toolbox.html : A fundamental precept of OO systems is that an object should not expose any of its implementation details. This way, you can change the implementation without changing the code that uses the object. It follows then that in OO systems you should avoid getter and setter functions since they mostly provide access to implementation details. To see why, consider that there might be 1,000 calls to a getX() method in your program, and each call assumes that the return value is of a particular type. You might store getX()'s return value in a local variable, for example, and that variable type must match the return-value type. If you need to change the way the object is implemented in such a way that the type of X changes, you're in deep trouble. No,but in the first one, you can control, from within the class/method, what data is actually allowed to be injected into that variable. Whereas the second example would allow you to stuff any type of data into that class variable. That might not be a good thing. That's a relatively narrow minded response to my point, since I gave a pretty concrete example of exactly what I meant, followed by a great article which furthered my point. Let me quote, you said this: Is no different than You are wrong, in fact it IS different. Having your own custom methods to get or set data allows you to have more control over what data is injected into your object. I would call is a personal preference which may not work for you, but works fine for me. All I can say is that all my __set methods do data sanitizing and validation, which is were I think it should be done. If anybody thinks this might be a bad thing, please by all means explain why it is bad. The general rule of encapsulation is: Don't ask an object for data, ask the object to work with the data. I hope it checks the data first before using it. If you don't then you might end up with something you had not planned on. If I am not to ask an object for data how is my db class/object ever going to return me data from my database? What he means is don't ask for the data literally (by property name) ask for it via a method. This allows wrapping the data in work. This is a moot issue in PHP since PHP allows trapping the property accessor. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 and the DOM model
On Fri, Apr 18, 2008 at 12:50 PM, Jim Lucas [EMAIL PROTECTED] wrote: Let me quote, you said this: Is no different than You are wrong, in fact it IS different. Having your own custom methods to get or set data allows you to have more control over what data is injected into your object. lol. wait a second, jim, you think a class w/ 2 methods isnt the same as one w/ no methods :O I would call is a personal preference which may not work for you, but works fine for me. strangely enough, last year when we argued, it became clear the definition of encapsulation varies quite a bit across the people who subscribe to this list, tho i posted 4 examples from texts ive read over the years that all essentialY incorporate data hiding into the definition of encapsulation. All I can say is that all my __set methods do data sanitizing and validation, which is were I think it should be done. If anybody thinks this might be a bad thing, please by all means explain why it is bad. right; 100%. and even if setters are as simple as function setStuff($stuff) { $this-stuff = $stuff; } the client is still being driven through a well defined public interface, which supports the ability to add validation logic later on w/o impacting client code. you could also change the internal variable from $stuff to $goofy and it would be transparent to the client. the point here is indirection, which in programming terms is basically synonymous w/ flexibility. yes there are costs, runtime performance, system complexity, but these are the tradeoffs for flexibility. when you take it to a higher level thats what design patterns are all about. standardized techniques to incorporate flexibility into an application. -nathan
Re: [PHP] PHP5 and the DOM model
On Fri, Apr 18, 2008 at 1:02 PM, Robert Cummings [EMAIL PROTECTED] wrote: What he means is don't ask for the data literally (by property name) ask for it via a method. This allows wrapping the data in work. This is a moot issue in PHP since PHP allows trapping the property accessor. i dont think its moot. if your trapping it via __get() or __set() its still the same action; driving the client through a well defined interface; if it just happens to have the same name as the property itself, its still the same concept. you have the 'work' in the magic methods (at a minimum the initial part), instead of the getters and setters you would build yourself. and personally, i think it much cleaner to have separate methods for each of the properties rather than one big function which has to internally route control via some sort of logic, be it conditional, variable functions or w/e. besides which, for the magic methods to work, the variables have to be 'inaccessible' according to the docs which means protected, private, or non-existent; and barring the case of non-existent we are right back in the realm of encapsulation. unless you meant something different by 'trapping the property accessor'; which you usually do pull some unexpected stuff so im waiting for your next clever example to prove me wrong :D nathan-nobbes-macbook-pro:~ nnobbe$ cat testSet.php ?php class A { public $blah; protected $meh; private $dude; function __get($var) { echo __METHOD__ . PHP_EOL; } function __set($var, $val) { echo __METHOD__ . var: $var . PHP_EOL; } } $a = new A(); $a-blah = 5; $a-meh = 6; $a-dude = 7; $a-fake = 8; ? nathan-nobbes-macbook-pro:~ nnobbe$ php testSet.php A::__set var: meh A::__set var: dude A::__set var: fake -nathan
Re: [PHP] PHP5 and the DOM model
On Fri, 2008-04-18 at 13:17 -0600, Nathan Nobbe wrote: On Fri, Apr 18, 2008 at 1:02 PM, Robert Cummings [EMAIL PROTECTED] wrote: What he means is don't ask for the data literally (by property name) ask for it via a method. This allows wrapping the data in work. This is a moot issue in PHP since PHP allows trapping the property accessor. i dont think its moot. if your trapping it via __get() or __set() its still the same action; driving the client through a well defined interface; if it just happens to have the same name as the property itself, its still the same concept. you have the 'work' in the magic methods (at a minimum the initial part), instead of the getters and setters you would build yourself. and personally, i think it much cleaner to have separate methods for each of the properties rather than one big function which has to internally route control via some sort of logic, be it conditional, variable functions or w/e. besides which, for the magic methods to work, the variables have to be 'inaccessible' according to the docs which means protected, private, or non-existent; and barring the case of non-existent we are right back in the realm of encapsulation. unless you meant something different by 'trapping the property accessor'; which you usually do pull some unexpected stuff so im waiting for your next clever example to prove me wrong :D Nope, the point is moot. If I've made my properties publicly accessible, now, due to the ability to trap via __get() or __set(), I can remove them and handle them. Thus, I can retrospectively change the semantics without care for having exposed the properties themselves. The point is moot here because the option now exists to enhance properties at a later date without the need to drive the enhancements through a method the user must call (the details of __get() and __set() are hidden from the user of the properties ;) Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 and the DOM model
On Fri, Apr 18, 2008 at 1:42 PM, Robert Cummings [EMAIL PROTECTED] wrote: Nope, the point is moot. If I've made my properties publicly accessible, now, due to the ability to trap via __get() or __set(), I can remove them and handle them. Thus, I can retrospectively change the semantics without care for having exposed the properties themselves. The point is moot here because the option now exists to enhance properties at a later date without the need to drive the enhancements through a method the user must call (the details of __get() and __set() are hidden from the user of the properties ;) i see your rationale now, and yes i agree, using the magic methods does afford the ability to make transparent changes and thats great. however, what im saying is thats still encapsulation, just a different way of attaining it. and the other negative of that approach is having to bulk up the logic in the magic methods. i tend to use them to handle attempts to access non-existent params. actually, tho drifting a bit; i think the __call() magic method is great because it allows handling of what would otherwise be a fatal error when trying to invoke a non-existent class method. -nathan
Re: [PHP] PHP5 and the DOM model
On Fri, 2008-04-18 at 13:54 -0600, Nathan Nobbe wrote: On Fri, Apr 18, 2008 at 1:42 PM, Robert Cummings [EMAIL PROTECTED] wrote: Nope, the point is moot. If I've made my properties publicly accessible, now, due to the ability to trap via __get() or __set(), I can remove them and handle them. Thus, I can retrospectively change the semantics without care for having exposed the properties themselves. The point is moot here because the option now exists to enhance properties at a later date without the need to drive the enhancements through a method the user must call (the details of __get() and __set() are hidden from the user of the properties ;) i see your rationale now, and yes i agree, using the magic methods does afford the ability to make transparent changes and thats great. however, what im saying is thats still encapsulation, just a different way of attaining it. I'm not arguing against encapsulation, only indicating that there's no longer a point to differentiating between method wrapping and property access in PHP (although maybe there's some fringe differences-- I haven't played with it much at this time). and the other negative of that approach is having to bulk up the logic in the magic methods. i tend to use them to handle attempts to access non-existent params. Why bulk up your magic methods? Keep them slim... ?php class Foo { function __get( $name ) { if( method_exists( $this, 'get'.ucFirst( $name ) ) ) { return $this-{'get'.ucFirst( $name )}(); } return null; } function getName() { return 'Namicus Orealeeyus'; } } $foo = new Foo(); echo $foo-name.\n; ? Or if you want to pick and choose... ?php class Foo { function __get( $name ) { static $map = array ( 'name' = 'getName', ); if( isset( $map[$name] ) ) { return $this-{$map[$name]}(); } return null; } function getName() { return 'Namicus Orealeeyus'; } } ? actually, tho drifting a bit; i think the __call() magic method is great because it allows handling of what would otherwise be a fatal error when trying to invoke a non-existent class method. Very useful for things like SOAP. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 and the DOM model
On Fri, Apr 18, 2008 at 2:28 PM, Robert Cummings [EMAIL PROTECTED] wrote: On Fri, 2008-04-18 at 13:54 -0600, Nathan Nobbe wrote: On Fri, Apr 18, 2008 at 1:42 PM, Robert Cummings [EMAIL PROTECTED] wrote: Nope, the point is moot. If I've made my properties publicly accessible, now, due to the ability to trap via __get() or __set(), I can remove them and handle them. Thus, I can retrospectively change the semantics without care for having exposed the properties themselves. The point is moot here because the option now exists to enhance properties at a later date without the need to drive the enhancements through a method the user must call (the details of __get() and __set() are hidden from the user of the properties ;) i see your rationale now, and yes i agree, using the magic methods does afford the ability to make transparent changes and thats great. however, what im saying is thats still encapsulation, just a different way of attaining it. I'm not arguing against encapsulation, only indicating that there's no longer a point to differentiating between method wrapping and property access in PHP (although maybe there's some fringe differences-- I haven't played with it much at this time). and the other negative of that approach is having to bulk up the logic in the magic methods. i tend to use them to handle attempts to access non-existent params. Why bulk up your magic methods? Keep them slim... ?php class Foo { function __get( $name ) { if( method_exists( $this, 'get'.ucFirst( $name ) ) ) { return $this-{'get'.ucFirst( $name )}(); } return null; } function getName() { return 'Namicus Orealeeyus'; } } $foo = new Foo(); echo $foo-name.\n; ? Or if you want to pick and choose... ?php class Foo { function __get( $name ) { static $map = array ( 'name' = 'getName', ); if( isset( $map[$name] ) ) { return $this-{$map[$name]}(); } return null; } function getName() { return 'Namicus Orealeeyus'; } } ? i know; variable functions are cool, but still, i guess it comes down to a matter of prefernce class Foo { function __get( $name ) { if( !is_set( $this-$name) ) { // some logic for handling non-existent getters } return null; } /// only getters i care about function getStuff() {} /// etc .. } ? -nathan
[PHP] PHP5 and the DOM model
Hello! Seems that PHP gets more and more object oriented, which is good. I am now running a course in PHP, using PHP 5, where we are going to use the *DOM* interface. I am trying to teach them good OO practices, meaning that we insistently hide properties and expose them as get or set methods. Looking at the PHPs *DOM* implementation, I see that many of the properties are exposed directly, without even offering get methods. 1. Is there something I am misunderstanding orotherwise missing? (I havenot used *DOM* in PHP before). 2.This poses a pedagogical problem for me as a teacher. How do I explain this contradiction to my students? Thanks Michael -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP5 strtotime
I use PayPal as my ecommerce solution and I have a PHP script that captures variables posted from PayPal to populate my database. The time variable string is sent in the following format: HH:MM:SS DD Mmm YY, PST. The script worked fine but since I upgraded to PHP5 the dates inputted into my database (MySQL) are showing some date in 1969. Can anyone say what is causing this or how to correct it? Thanks. Samuel Marshall
Re: [PHP] PHP5 strtotime
On Monday 10 March 2008, Samuel Marshall wrote: I use PayPal as my ecommerce solution and I have a PHP script that captures variables posted from PayPal to populate my database. The time variable string is sent in the following format: HH:MM:SS DD Mmm YY, PST. The script worked fine but since I upgraded to PHP5 the dates inputted into my database (MySQL) are showing some date in 1969. Can anyone say what is causing this or how to correct it? Thanks. Samuel Marshall PHP's error value for dates translates to 6 PM 31 December 1969 when formatted, that is, right before the Epoc. That happens when you feed strtotime a string it can't parse, for instance. Looking at the string you list, the year is listed twice. I very much doubt strtotime can grok that. You'll need to do at least some manual parsing of the date string. -- Larry Garfield AIM: LOLG42 [EMAIL PROTECTED] ICQ: 6817012 If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it. -- Thomas Jefferson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP5 and XSLTProcessor: disable validation
Hi, i'm currently learning php by implementing a blog system. This uses xsl for transformation to (x)html. It is working so far, but it is slow. As far as i can see the XSLTProcessor is doing a validation. Doing the same transformation with xsltproc (the command line tool for libxslt) takes about the same time. Adding the parameter --novalid to xsltproc speeds up things dramatically. Is there any possibility/option/parameter/whatever to stop XSLTProcessor validation? I've found nothing in the documentation. I hope i'm not wrong here. I'm new to php as well as to this list :) regards Siegfried Gipp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 Speed Issues
Hi everyone! Generaly author of the first e-mail is right. Ofcource, crawling over the code and getting out of it a few milliseconds off doesn't make it worth, but you can learn what is good and what is bad and write your code correctly from the start. Why not to use foreach ($data as $value) if it's better - faster and takes less memory. That's just a habbit on code style. I can bet, that nobody knows or remembers that echo has alternative syntax, with works faster and is easier to write if you cave to echo a complex string with many variables and static text, for example The ordinary: echo 'Hi! My name is '.$_GET['name'].'. I'm '.$_GET['age'].' and I live in '.$_GET['country'].'.'; The alternative: echo 'Hi! My name is', $_GET['name'], '. I'm ', $_GET['age'], ' and I live in ', $_GET['country'], '.'; I have an aplication with doesn't eat all CPU, just about 50-60%, but it eats all 3GB of ram. And not because it is poorly written. It serves ~160 000 - 170 000 requests/hour, that's ~3 960 000 hits a day + another 600 000 hits to the application's WEB part. Just one server could handle, but it can't because of WEB server's FastCGI implementation (they have a patch for that soon released). Just ONE Intel E6600 server with Lighttpd and PHP can handle such load if the code is optimised and written correctly.
Re: [PHP] PHP5 Speed Issues
On Sat, December 22, 2007 12:25 pm, Sascha Braun wrote: Hi Fellows, I figured out, that PHP5 runs faster when I am not inherit classes, I hope I use the right word. I mean the class sub_class extends main_class notation. As well I figured out, that I in most cases should references in foreach loops. like foreach($array as $key = $value) { } Lots of memory is saved by that. Now I would like to know, what other speed improvements might be possible. What about autoload of classes, will it improve speed when I throw the code out? Are there other things I should take care of. I would like to know as much as possible. Please go deep into your- self and tell me every little thing on how you improved your applica- tions for speed and memory optimisation, to make this thread the best compendium on performance and memory optimisation. Thank you very much, fellows and a merry merry christmas! I never optimize code unless there's a problem with its performance... Why one would tweak code endlessly to maximize performance when that's not needed is beyond me... But maybe I'm just a Luddite. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 Speed Issues
Richard Lynch wrote: On Sat, December 22, 2007 12:25 pm, Sascha Braun wrote: Hi Fellows, I figured out, that PHP5 runs faster when I am not inherit classes, I hope I use the right word. I mean the class sub_class extends main_class notation. As well I figured out, that I in most cases should references in foreach loops. like foreach($array as $key = $value) { } Lots of memory is saved by that. Now I would like to know, what other speed improvements might be possible. What about autoload of classes, will it improve speed when I throw the code out? Are there other things I should take care of. I would like to know as much as possible. Please go deep into your- self and tell me every little thing on how you improved your applica- tions for speed and memory optimisation, to make this thread the best compendium on performance and memory optimisation. Thank you very much, fellows and a merry merry christmas! I never optimize code unless there's a problem with its performance... Why one would tweak code endlessly to maximize performance when that's not needed is beyond me... But maybe I'm just a Luddite. Hardware is cheaper than man hours. Just throw more CPU power at the problem. -- Michael McGlothlin Southwest Plumbing Supply -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 Speed Issues
On Dec 31, 2007 3:37 PM, Michael McGlothlin [EMAIL PROTECTED] wrote: Richard Lynch wrote: On Sat, December 22, 2007 12:25 pm, Sascha Braun wrote: Hi Fellows, I figured out, that PHP5 runs faster when I am not inherit classes, I hope I use the right word. I mean the class sub_class extends main_class notation. As well I figured out, that I in most cases should references in foreach loops. like foreach($array as $key = $value) { } Lots of memory is saved by that. Now I would like to know, what other speed improvements might be possible. What about autoload of classes, will it improve speed when I throw the code out? Are there other things I should take care of. I would like to know as much as possible. Please go deep into your- self and tell me every little thing on how you improved your applica- tions for speed and memory optimisation, to make this thread the best compendium on performance and memory optimisation. Thank you very much, fellows and a merry merry christmas! I never optimize code unless there's a problem with its performance... Why one would tweak code endlessly to maximize performance when that's not needed is beyond me... But maybe I'm just a Luddite. Hardware is cheaper than man hours. Just throw more CPU power at the problem. thats only true until poorly designed software cant be spread across machines due to a monolithic nature. get an opcode cache and index the database; that will probly absolve any noticeable speed problems. -nathan
Re: [PHP] PHP5 Speed Issues
Nathan Nobbe wrote: On Dec 31, 2007 3:37 PM, Michael McGlothlin [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Richard Lynch wrote: On Sat, December 22, 2007 12:25 pm, Sascha Braun wrote: Hi Fellows, I figured out, that PHP5 runs faster when I am not inherit classes, I hope I use the right word. I mean the class sub_class extends main_class notation. As well I figured out, that I in most cases should references in foreach loops. like foreach($array as $key = $value) { } Lots of memory is saved by that. Now I would like to know, what other speed improvements might be possible. What about autoload of classes, will it improve speed when I throw the code out? Are there other things I should take care of. I would like to know as much as possible. Please go deep into your- self and tell me every little thing on how you improved your applica- tions for speed and memory optimisation, to make this thread the best compendium on performance and memory optimisation. Thank you very much, fellows and a merry merry christmas! I never optimize code unless there's a problem with its performance... Why one would tweak code endlessly to maximize performance when that's not needed is beyond me... But maybe I'm just a Luddite. Hardware is cheaper than man hours. Just throw more CPU power at the problem. thats only true until poorly designed software cant be spread across machines due to a monolithic nature. get an opcode cache and index the database; that will probly absolve any noticeable speed problems. -nathan Well obviously you can always write horrible code but if you write code that is easy to maintain it's usually not that kind of code. -- Michael McGlothlin Southwest Plumbing Supply -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 Speed Issues
On Dec 31, 2007 3:47 PM, Michael McGlothlin [EMAIL PROTECTED] wrote: Nathan Nobbe wrote: On Dec 31, 2007 3:37 PM, Michael McGlothlin [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Richard Lynch wrote: On Sat, December 22, 2007 12:25 pm, Sascha Braun wrote: Hi Fellows, I figured out, that PHP5 runs faster when I am not inherit classes, I hope I use the right word. I mean the class sub_class extends main_class notation. As well I figured out, that I in most cases should references in foreach loops. like foreach($array as $key = $value) { } Lots of memory is saved by that. Now I would like to know, what other speed improvements might be possible. What about autoload of classes, will it improve speed when I throw the code out? Are there other things I should take care of. I would like to know as much as possible. Please go deep into your- self and tell me every little thing on how you improved your applica- tions for speed and memory optimisation, to make this thread the best compendium on performance and memory optimisation. Thank you very much, fellows and a merry merry christmas! I never optimize code unless there's a problem with its performance... Why one would tweak code endlessly to maximize performance when that's not needed is beyond me... But maybe I'm just a Luddite. Hardware is cheaper than man hours. Just throw more CPU power at the problem. thats only true until poorly designed software cant be spread across machines due to a monolithic nature. get an opcode cache and index the database; that will probly absolve any noticeable speed problems. -nathan Well obviously you can always write horrible code but if you write code that is easy to maintain it's usually not that kind of code. thats pretty subjective; ive worked w/ plenty of 'easy to maintain' code that could only have hardware thrown at it by a load balancer. which i consider a real mess. even then the design of the load balancer will have to maintain request forwarding to particular hosts unless the code already supports or is given support for session storage in a common location all the webservers can address. i personally am not a fan of the 'just throw hardware at it' adage, if it can be called that. i was recently at the d.c. php conference and heard a talk from a gentleman on behalf of yahoo. he says they are *very* picky about getting new hardware; yahoo wants clear rationale for the addition of any new hardware into the system. in short; they advocate writing solid code because it saves them money in the long run. what i see happening when people throw hardware at their problem is that in early stages it works great. then further down the road the software is unable to be easily spread to multiple systems and then guess what; you end up spending man hours to do something that could have been done in the first place. another issue is randomly added machines can be hard to maintain because their roles are not clearly defined. what im saying is adding hardware to a system is natural and relevant, but ensure it is a good decision by evaluating alternatives before arbitrarily 'throwing hardware at the problem'. -nathan
[PHP] PHP5 Speed Issues
Hi Fellows, I figured out, that PHP5 runs faster when I am not inherit classes, I hope I use the right word. I mean the class sub_class extends main_class notation. As well I figured out, that I in most cases should references in foreach loops. like foreach($array as $key = $value) { } Lots of memory is saved by that. Now I would like to know, what other speed improvements might be possible. What about autoload of classes, will it improve speed when I throw the code out? Are there other things I should take care of. I would like to know as much as possible. Please go deep into your- self and tell me every little thing on how you improved your applica- tions for speed and memory optimisation, to make this thread the best compendium on performance and memory optimisation. Thank you very much, fellows and a merry merry christmas! Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php5 - possible bug discovered
Hi Robert, Stut List Thanks for your replies which arrived after I had gone to bed |-Z Robert :- In PHP5 objects are no longer copied when assigned. Instead the object's handle is assigned (similar to a reference but not quite). So the behaviour is as expected. Stut :- I think I have discovered a bug in php5. If I haven't, I've discovered a bug in the documentation or a bug in my brain. Start here: http://php.net/language.oop5.cloning It's amazing what a good night's sleep will do :-) I could not find that page last night even though I was sure it must have existed and I can see that it is a well documented and encountered problem. My main obesrvation is that I'm glad that I decided to revisit all my old PHP4 stuff and rewrite or clean it up. I have hundreds of $Working_Class = $Under_Class; lines in my code as well as $Upper_Class = $Aristocracy; lines too. I think the documentation on references needs updating to reflect PHP 5's behaviour a little more accurately because I can see this causing serious problems to somebody just copying their code blindly. I have just built a client a development server using php5 instead of php4 and turned zend.ze1_compatibility_mode on so that their old CMS would work - I just hadn't realised that the cloning problem was solved by this. Oh well, now I'm fresh I can crack on :-) TTFN D php/general-2007-10-09.tx [EMAIL PROTECTED] [EMAIL PROTECTED] php-general ++ | Dave Restall, Computer Nerd, Cyclist, Radio Amateur G4FCU, Bodger | | Mob +44 (0) 7973 831245 Skype: dave.restall Radio: G4FCU | | email : [EMAIL PROTECTED] Web : Not Ready Yet :-( | ++ | birth, n: | | The first and direst of all disasters. | | -- Ambrose Bierce, The Devil's Dictionary| ++ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php5 - possible bug discovered
David Restall - System Administrator wrote: My main obesrvation is that I'm glad that I decided to revisit all my old PHP4 stuff and rewrite or clean it up. I have hundreds of $Working_Class = $Under_Class; lines in my code as well as $Upper_Class = $Aristocracy; lines too. I think the documentation on references needs updating to reflect PHP 5's behaviour a little more accurately because I can see this causing serious problems to somebody just copying their code blindly. This change was made very clear in the changelog for PHP5. Whenever you change to a different PHP version the changelog should be the first thing you read. If you try to read the documentation to pick out the changes you'll miss something. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP5 under IIS6
Hi fellows: I'm trying to mount PHP5 ( the last stable version from php.net) under a IIS6 (win2k3 SP2), and when I run the .msi and it finish it said that is not possible the configure httpd.conf, which is a very big mistake 'cause I'm specify that I use IIS6. After that I try making a manual configuration and I recive a CGI error. I need help ASAP. Este correo ha sido enviado desde el Politécnico de Informática Carlos Marx de Matanzas. La gran batalla se librará en el campo de las ideas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 under IIS6
Hi Alberto, Try using the php5isapi.dll instead of CGI. Make sure you have an entry for PHP5 in your Web Service Extensions list, and that it is marked as Allowed. Also, open the properties of your Web Sites folder in IIS Manager, go to the Home Directory Tab, click Configuration, and make sure the php5isapi.dll is mapped to the .php extension. Regards, Carlton Whitehead - Original Message - From: Alberto García Gómez [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Monday, October 8, 2007 9:57:42 AM (GMT-0500) America/New_York Subject: [PHP] PHP5 under IIS6 Hi fellows: I'm trying to mount PHP5 ( the last stable version from php.net) under a IIS6 (win2k3 SP2), and when I run the .msi and it finish it said that is not possible the configure httpd.conf, which is a very big mistake 'cause I'm specify that I use IIS6. After that I try making a manual configuration and I recive a CGI error. I need help ASAP. Este correo ha sido enviado desde el Politécnico de Informática Carlos Marx de Matanzas. La gran batalla se librará en el campo de las ideas -- 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
[PHP] php5 - possible bug discovered
Hi, I think I have discovered a bug in php5. If I haven't, I've discovered a bug in the documentation or a bug in my brain. php -v :- PHP 5.2.3 (cli) (built: Jun 26 2007 15:38:48) Copyright (c) 1997-2007 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies I've attached a code snippet for those that want to save it and try running it and it's also pasted here :- ?php class Class_1 { private $Text; function __construct($Text) { $this-Text = $Text; } function Set($Text) { $this-Text = $Text; } function Display() { print $this-Text . \n; } } // End Class_1 class Class_2 { private $Text; private $C1; function __construct($Text) { $this-Text = $Text; $this-C1 = new Class_1('From David'); } function Set_C1($Text) { $this-C1-Set($Text); } function Display() { print $this-Text . \n; $this-C1-Display(); } } // End Class_2 print Below is T1\n; $T1 = new Class_1('Hello'); $T1-Display(); print Below is T2\n; $T2 = new Class_2('World'); $T2-Display(); print Copying T2\n; $T3 = $T2; print T2 Copied, original value is :-\n; $T2-Display(); print Copy of T2 (T3) value is :- \n; $T3-Display(); print Changing T3\n; $T3-Set_C1(This clears Dave); print T3 Change complete, new value is :-\n; $T3-Display(); print Below is T2 which shouldn't have changed !!! \n; $T2-Display(); // var_dump($T1); ? The output it produces is :- % php -e bug.php Below is T1 Hello Below is T2 World From David Copying T2 T2 Copied, original value is :- World From David Copy of T2 (T3) value is :- World From David Changing T3 T3 Change complete, new value is :- World This clears Dave Below is T2 which shouldn't have changed !!! World This clears Dave % Now I would expect that $T2 would not change when I changed $T3. Reading the documentation :- http://www.php.net/manual/en/language.references.whatdo.php ... Note: Not using the operator causes a copy of the object to be made. If you use $this in the class it will operate on the current instance of the class. The assignment without will copy the instance (i.e. the object) and $this will operate on the copy, which is not always what is desired. Usually you want to have a single instance to work with, due to performance and memory consumption issues. This effectively states that $T3 is a 'COPY' of $T2 and $T3 works on the copy, not the master yet in the above snippet, the copy and the master have both been changed. Further documentation mentions that the copy starts off as a reference and only becomes a copy when it is changed. This doesn't seem to be happening. I found this because in my actual application I was using :- Master.class ... $Clone = $this; $Clone-Do_Something; and later in master.class I did :- $this-Do_Something_Else and php barfed with :- PHP Fatal error: Call to a member function Function_Name() on a non-object I had deleted the missing object in $Clone but not in the master (this was the whole idea of working on $Clone - I didn't want to delete the object in the master !!). I can't find anything similar in the bug database on php.net (but I may be looking in the wrong place) and I can't believe that I'm the first person to encounter this. Can anybody explain if this is a bug or if I have misunderstood the documentation ? TTFN D php/general-2007-10-08.tx php-general ++ | Dave Restall, Computer Nerd, Cyclist, Radio Amateur G4FCU, Bodger | | Mob +44 (0) 7973 831245 Skype: dave.restall Radio: G4FCU | | email : [EMAIL PROTECTED] Web : Not Ready Yet :-( | ++ | Good salesmen and good repairmen will never go hungry. | | -- R. E. Schenk| ++ bug.php Description: application/httpd-php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php5 - possible bug discovered
In PHP5 objects are no longer copied when assigned. Instead the object's handle is assigned (similar to a reference but not quite). So the behaviour is as expected. Cheers, Rob. On Mon, 2007-10-08 at 21:42 +0100, David Restall - System Administrator wrote: Hi, I think I have discovered a bug in php5. If I haven't, I've discovered a bug in the documentation or a bug in my brain. php -v :- PHP 5.2.3 (cli) (built: Jun 26 2007 15:38:48) Copyright (c) 1997-2007 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies I've attached a code snippet for those that want to save it and try running it and it's also pasted here :- ?php class Class_1 { private $Text; function __construct($Text) { $this-Text = $Text; } function Set($Text) { $this-Text = $Text; } function Display() { print $this-Text . \n; } } // End Class_1 class Class_2 { private $Text; private $C1; function __construct($Text) { $this-Text = $Text; $this-C1 = new Class_1('From David'); } function Set_C1($Text) { $this-C1-Set($Text); } function Display() { print $this-Text . \n; $this-C1-Display(); } } // End Class_2 print Below is T1\n; $T1 = new Class_1('Hello'); $T1-Display(); print Below is T2\n; $T2 = new Class_2('World'); $T2-Display(); print Copying T2\n; $T3 = $T2; print T2 Copied, original value is :-\n; $T2-Display(); print Copy of T2 (T3) value is :- \n; $T3-Display(); print Changing T3\n; $T3-Set_C1(This clears Dave); print T3 Change complete, new value is :-\n; $T3-Display(); print Below is T2 which shouldn't have changed !!! \n; $T2-Display(); // var_dump($T1); ? The output it produces is :- % php -e bug.php Below is T1 Hello Below is T2 World From David Copying T2 T2 Copied, original value is :- World From David Copy of T2 (T3) value is :- World From David Changing T3 T3 Change complete, new value is :- World This clears Dave Below is T2 which shouldn't have changed !!! World This clears Dave % Now I would expect that $T2 would not change when I changed $T3. Reading the documentation :- http://www.php.net/manual/en/language.references.whatdo.php ... Note: Not using the operator causes a copy of the object to be made. If you use $this in the class it will operate on the current instance of the class. The assignment without will copy the instance (i.e. the object) and $this will operate on the copy, which is not always what is desired. Usually you want to have a single instance to work with, due to performance and memory consumption issues. This effectively states that $T3 is a 'COPY' of $T2 and $T3 works on the copy, not the master yet in the above snippet, the copy and the master have both been changed. Further documentation mentions that the copy starts off as a reference and only becomes a copy when it is changed. This doesn't seem to be happening. I found this because in my actual application I was using :- Master.class ... $Clone = $this; $Clone-Do_Something; and later in master.class I did :- $this-Do_Something_Else and php barfed with :- PHP Fatal error: Call to a member function Function_Name() on a non-object I had deleted the missing object in $Clone but not in the master (this was the whole idea of working on $Clone - I didn't want to delete the object in the master !!). I can't find anything similar in the bug database on php.net (but I may be looking in the wrong place) and I can't believe that I'm the first person to encounter this. Can anybody explain if this is a bug or if I have misunderstood the documentation ? TTFN D php/general-2007-10-08.tx php-general ++ | Dave Restall, Computer Nerd, Cyclist, Radio Amateur G4FCU, Bodger | | Mob +44 (0) 7973 831245 Skype: dave.restall Radio: G4FCU | | email : [EMAIL PROTECTED] Web : Not Ready Yet :-( | ++ | Good salesmen and good repairmen will never go hungry. | | -- R. E. Schenk| ++ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
Re: [PHP] php5 - possible bug discovered
David Restall - System Administrator wrote: I think I have discovered a bug in php5. If I haven't, I've discovered a bug in the documentation or a bug in my brain. Start here: http://php.net/language.oop5.cloning -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php5: capital I letters in func/class method names do not work with turkish locale in php5
On Thu, 06 Sep 2007 15:57:57 +0300, Tijnema [EMAIL PROTECTED] wrote: On 9/6/07, Roman Neumüller [EMAIL PROTECTED] wrote: I'm a german web-designer living in Turkey. Sometimes I use opensource software like gallery2 or WP to have customers have some nice web albums or blog. The turkish translation files of such opensource software usually use gettext and .po files for i18n and are always a bit behind the translation status of other european languages. I decided to work a bit on some of those tr.po files on my local linux box (opensuse 10.2 with apache 2.x mysql 5.x and php 5.2.0). But when I started the test phase in turkish I couldn't test because of strange errors. I contacted the forum of gallery2 and after investigating the problem I stumbled over an answer of bug #35050 at bugs.php.net: http://bugs.php.net/bug.php?id=35050 and its status: WONT FIX Now that's really great. It means that turkish hosting providers cannot use php5 at all! And as of the news on php.net php4 will not be supported or developed any further after the end of 2007! Will Turks really have now to wait for a php6? When will that come out? That's seems to me to be a sort of discrimination of turkish language in php5. Is it technical so difficult to develop a patch for this bug? Sincerely Well, only 1 hour later than your email, there has been posted a patch on the bug page that fixes it. Tijnema I had a look at the patch under http://www.topolis.lt/php/#35050 and saw it did not work for my system (php5.2.0) I wrote to the author of the patch and got this answer: Patch is written for PHP 5.2.5-dev. It should work in 6.0-dev and PHP 5.2.1 or later version. Any version later than 2006-12-05. But he also said: If you need workaround, just set LC_CTYPE locale to C. It also deals with programming mistakes in PHP scripts.setlocale(LC_ALL,'tr_TR.UTF-8'); setlocale(LC_CTYPE, 'C'); and that seems to work - at least in case of my gallery2 under php5.2.0. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php5: capital I letters in func/class method names do not work with turkish locale in php5
I'm a german web-designer living in Turkey. Sometimes I use opensource software like gallery2 or WP to have customers have some nice web albums or blog. The turkish translation files of such opensource software usually use gettext and .po files for i18n and are always a bit behind the translation status of other european languages. I decided to work a bit on some of those tr.po files on my local linux box (opensuse 10.2 with apache 2.x mysql 5.x and php 5.2.0). But when I started the test phase in turkish I couldn't test because of strange errors. I contacted the forum of gallery2 and after investigating the problem I stumbled over an answer of bug #35050 at bugs.php.net: http://bugs.php.net/bug.php?id=35050 and its status: WONT FIX Now that's really great. It means that turkish hosting providers cannot use php5 at all! And as of the news on php.net php4 will not be supported or developed any further after the end of 2007! Will Turks really have now to wait for a php6? When will that come out? That's seems to me to be a sort of discrimination of turkish language in php5. Is it technical so difficult to develop a patch for this bug? Sincerely -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php5: capital I letters in func/class method names do not work with turkish locale in php5
On 9/6/07, Roman Neumüller [EMAIL PROTECTED] wrote: I'm a german web-designer living in Turkey. Sometimes I use opensource software like gallery2 or WP to have customers have some nice web albums or blog. The turkish translation files of such opensource software usually use gettext and .po files for i18n and are always a bit behind the translation status of other european languages. I decided to work a bit on some of those tr.po files on my local linux box (opensuse 10.2 with apache 2.x mysql 5.x and php 5.2.0). But when I started the test phase in turkish I couldn't test because of strange errors. I contacted the forum of gallery2 and after investigating the problem I stumbled over an answer of bug #35050 at bugs.php.net: http://bugs.php.net/bug.php?id=35050 and its status: WONT FIX Now that's really great. It means that turkish hosting providers cannot use php5 at all! And as of the news on php.net php4 will not be supported or developed any further after the end of 2007! Will Turks really have now to wait for a php6? When will that come out? That's seems to me to be a sort of discrimination of turkish language in php5. Is it technical so difficult to develop a patch for this bug? Sincerely Well, only 1 hour later than your email, there has been posted a patch on the bug page that fixes it. Tijnema -- If this is a mailing list: DO NOT TOP POST! why?: http://www.caliburn.nl/topposting.html Vote for PHP Color Coding (aka Syntax Highlighting) in Gmail! - http://gpcc.tijnema.info -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php5: capital I letters in func/class method names do not work with turkish locale in php5
Now that's service! On 9/6/07, Tijnema [EMAIL PROTECTED] wrote: On 9/6/07, Roman Neumüller [EMAIL PROTECTED] wrote: I'm a german web-designer living in Turkey. Sometimes I use opensource software like gallery2 or WP to have customers have some nice web albums or blog. The turkish translation files of such opensource software usually use gettext and .po files for i18n and are always a bit behind the translation status of other european languages. I decided to work a bit on some of those tr.po files on my local linux box (opensuse 10.2 with apache 2.x mysql 5.x and php 5.2.0). But when I started the test phase in turkish I couldn't test because of strange errors. I contacted the forum of gallery2 and after investigating the problem I stumbled over an answer of bug #35050 at bugs.php.net: http://bugs.php.net/bug.php?id=35050 and its status: WONT FIX Now that's really great. It means that turkish hosting providers cannot use php5 at all! And as of the news on php.net php4 will not be supported or developed any further after the end of 2007! Will Turks really have now to wait for a php6? When will that come out? That's seems to me to be a sort of discrimination of turkish language in php5. Is it technical so difficult to develop a patch for this bug? Sincerely Well, only 1 hour later than your email, there has been posted a patch on the bug page that fixes it. Tijnema -- If this is a mailing list: DO NOT TOP POST! why?: http://www.caliburn.nl/topposting.html Vote for PHP Color Coding (aka Syntax Highlighting) in Gmail! - http://gpcc.tijnema.info -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php5: capital I letters in func/class method names do not work with turkish locale in php5
On Thu, 06 Sep 2007 15:57:57 +0300, Tijnema [EMAIL PROTECTED] wrote: On 9/6/07, Roman Neumüller [EMAIL PROTECTED] wrote: I'm a german web-designer living in Turkey. Sometimes I use opensource software like gallery2 or WP to have customers have some nice web albums or blog. The turkish translation files of such opensource software usually use gettext and .po files for i18n and are always a bit behind the translation status of other european languages. I decided to work a bit on some of those tr.po files on my local linux box (opensuse 10.2 with apache 2.x mysql 5.x and php 5.2.0). But when I started the test phase in turkish I couldn't test because of strange errors. I contacted the forum of gallery2 and after investigating the problem I stumbled over an answer of bug #35050 at bugs.php.net: http://bugs.php.net/bug.php?id=35050 and its status: WONT FIX Now that's really great. It means that turkish hosting providers cannot use php5 at all! And as of the news on php.net php4 will not be supported or developed any further after the end of 2007! Will Turks really have now to wait for a php6? When will that come out? That's seems to me to be a sort of discrimination of turkish language in php5. Is it technical so difficult to develop a patch for this bug? Sincerely Well, only 1 hour later than your email, there has been posted a patch on the bug page that fixes it. Tijnema Now that's great! But... I had a view in my php5.2.0 source package in the Zend folder (phpinfo says: Zend Engine v2.2.0) for the file to be patched (zend_operators.c) and there is no such code in the file and no #define zend_tolower(c) What do I have to do now? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php5: capital I letters in func/class method names do not work with turkish locale in php5
On 9/6/07, Tijnema [EMAIL PROTECTED] wrote: On 9/6/07, Roman Neumüller [EMAIL PROTECTED] wrote: I'm a german web-designer living in Turkey. Sometimes I use opensource software like gallery2 or WP to have customers have some nice web albums or blog. The turkish translation files of such opensource software usually use gettext and .po files for i18n and are always a bit behind the translation status of other european languages. I decided to work a bit on some of those tr.po files on my local linux box (opensuse 10.2 with apache 2.x mysql 5.x and php 5.2.0). But when I started the test phase in turkish I couldn't test because of strange errors. I contacted the forum of gallery2 and after investigating the problem I stumbled over an answer of bug #35050 at bugs.php.net: http://bugs.php.net/bug.php?id=35050 and its status: WONT FIX Now that's really great. It means that turkish hosting providers cannot use php5 at all! And as of the news on php.net php4 will not be supported or developed any further after the end of 2007! Will Turks really have now to wait for a php6? When will that come out? That's seems to me to be a sort of discrimination of turkish language in php5. Is it technical so difficult to develop a patch for this bug? Sincerely Well, only 1 hour later than your email, there has been posted a patch on the bug page that fixes it. Tijnema -- If this is a mailing list: DO NOT TOP POST! why?: http://www.caliburn.nl/topposting.html Vote for PHP Color Coding (aka Syntax Highlighting) in Gmail! - http://gpcc.tijnema.info -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I wouldn't hold my breath on that. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php5 as universal binary (Mac OsX)
hello, I have an problem with php5 as universal binary on Mac OsX. The universal binary was build on an intel mac and it works good... on an intel mac ;) When a friend it try on an ppc mac he had some problems. For example phpsqliteadmin say this error: Fatal error: Balloc() allocation exceeds list boundary in /Applications/xampp/xamppfiles/phpsqliteadmin/SPSQLite.class.php on line 998 And phpmyadmin loads and loads and loads and loads... BUT my php4 universal binary works perfect on intel and ppc macs... :/ My configure for php5 look like this: PREFIX=/Applications/xampp/xamppfiles SYSCONFDIR=/Applications/xampp/etc export LD_RUN_PATH=$PREFIX/lib export LD_LIBRARY_PATH=$PREFIX/lib export CFLAGS=-I$PREFIX/include -L$PREFIX/lib -isysroot /Developer/SDKs/MacOSX10.4u.sdk export CPPFLAGS=-I$PREFIX/include export CXXFLAGS=-I$PREFIX/include -L$PREFIX/lib export LDFLAGS=-L$PREFIX/lib -I$PREFIX/include export SOFLAGS=-L$PREFIX/lib CFLAGS=$CFLAGS -arch i386 -arch ppc ./configure --prefix=$PREFIX --program-suffix=-5.2.3 --libdir=$PREFIX/lib/php/php5 --includedir= $PREFIX/include/php/php5 --with-apxs2=$PREFIX/bin/apxs --with-config-file-path=$SYSCONFDIR --with-mysql=$PREFIX --disable-debug --enable-bcmath --enable-calendar --enable-ctype --enable-dbase --enable-discard-path --enable-exif --enable-filepro --enable-force-cgi-redirect --enable-ftp --enable-gd-imgstrttf --enable-gd-native-ttf --with-ttf --enable-magic-quotes --enable-memory-limit --enable-safe-mode --enable-shmop --enable-sigchild --enable-sysvsem --enable-sysvshm --enable-track-vars --enable-trans-sid --enable-wddx --enable-yp --with-ftp --with-ncurses= $PREFIX --with-gdbm=$PREFIX --with-jpeg-dir=$PREFIX --with-png-dir= $PREFIX --with-freetype-dir=$PREFIX --without-xpm --with-zlib=yes --with-zlib-dir=$PREFIX --with-openssl=$PREFIX --with-expat-dir=$PREFIX --enable-xslt=$PREFIX --with-xsl=$PREFIX --with-dom=$PREFIX --with-ldap= $PREFIX --with-gd=$PREFIX --with-mysql-sock=$PREFIX/var/mysql/mysql.sock --with-mcrypt=$PREFIX --with-mhash=$PREFIX --enable-sockets --with-curl=$PREFIX --enable-mbregex --enable-zend-multibyte --with-zip= $PREFIX --enable-exif --with-sqlite --with-libxml-dir=$PREFIX --enable-soap --enable-pcntl --enable-dbx --with-mysqli= $PREFIX/bin/mysql_config --with-bz2=$PREFIX --with-pear= $PREFIX/lib/php/pear --with-mssql=$PREFIX --with-imap-dir=$PREFIX --with-imap=$PREFIX --enable-mbstring=all --with-pgsql=shared,/usr --with-gettext=$PREFIX I don't think thats this are errors from the php-scripts, I think thats an problem with php. I hope you can help me to resolve this problem thanks, kleinweby -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP5 objects access/instantiation model
Hi, new to PHP5 and I have a question about the object model. I want to be able to create a class which is allows abstraction from specifics. So for one example, imagine a generic database connection wrapper which can have multiple drivers depending on the database used. Some of the functionality is generic, some is database specific (mysql_ , odbc_). So: Class MySQL_driver { public prop1 ; public connect() { echo Foo; } public runquery() { echo Foo; } ... } Class ODBC_driver { public prop1 ; public connect() { echo Foo; } public runquery() { echo Foo; } ... } Class generic { public $driver = null ; function __construct($connection_type) { if $this-connection_type = MySQL { $this-driver = new MySQL_Driver ; } else { $this-driver = new ODBC_Driver ; } } function authenticate { // Using the non-generic connect() from the selected driver $this-driver-prop1 = fooey // These references work fine from within the generic class echo $this-driver-prop1 ; echo $this-driver-function1 ; } function errors { // Reporting non-generic errors from the selected driver } function debug { } ... } $gen = new generic(MySQL) ; // Instantiate the generic database object, which determines its own driver $gen-driver-prop1 = fooey // but they fail from here echo $gen-driver-prop1 ; echo $gen-driver-function1 ; $gen-authenticate() ; // this works ok though, so everything is created correctly So I want to access generic functions as $generic-authenticate(), and database specific functions $generic-driver-runquery. This allows the top level code to be able to be completely generic and not know anything about the underlying database. But I can't ! I can't find a way of accessing the encapsulated object (driver) from the instantiator of generic. Is it possible ? I guess there are lots of workaround ways. I could write lots of middleman code in generic and use things like __set and __get etc but its lots of extra overhead. I also know I could use extends but that makes the code the wrong way around (MySQL_Driver would have to extend generic), hence the top-level application would have to include code to determine which driver to create rather than the db object determining its own connection driver to use. This is true also for just lumping everything in a single class per db type. Surely it must be possible ? Or am I missing something ? I also don't really get the idea of interface and abstract classes ? They don't seem to be any practical use ? Maybe that's me ? Anyway, not really relevant to this post ... Please, please can someone help !! Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP5 objects access/instantiation model (correction)
OK, so that came out fairly illegible. Try again: Hi, new to PHP5 (and the forums evidently !) and I have a question about the object model. I want to be able to create a class which is allows abstraction from specifics. So for one example, imagine a generic database connection wrapper which can have multiple drivers depending on the database used. Some of the functionality is generic, some is database specific (mysql_ , odbc_). So: Class MySQL_driver { public prop1 ; public connect() { echo Foo; } public runquery() { echo Foo; } ... } Class ODBC_driver { public prop1 ; public connect() { echo Foo; } public runquery() { echo Foo; } ... } Class generic { public $driver = null ; function __construct($connection_type) { if $this-connection_type = MySQL { $this-driver = new MySQL_Driver ; } else { $this-driver = new ODBC_Driver ; } } // Using the non-generic connect() from the selected driver function authenticate { $this-driver-prop1 = fooey // These references work fine from within // the generic class echo $this-driver-prop1 ; echo $this-driver-function1 ; } // Report non-generic errors from the selected driver function errors { } function debug { } ... } $gen = new generic(MySQL) ; // Instantiate the generic database object, which // determines its own driver $gen-driver-prop1 = fooey // but they fail from here echo $gen-driver-prop1 ; echo $gen-driver-function1 ; // this works ok though, so everything is created // correctly $gen-authenticate() ; So I want to access generic functions as $generic-authenticate(), and database specific functions $generic-driver-runquery. This allows the top level code to be able to be completely generic and not know anything about the underlying database. But I can't ! I can't find a way of accessing the encapsulated object (driver) from the instantiator of generic. Is it possible ? I guess there are lots of workaround ways. I could write lots of middleman code in generic and use things like __set and __get etc but its lots of extra overhead. I also know I could use extends but that makes the code the wrong way around (MySQL_Driver would have to extend generic), hence the top-level application would have to include code to determine which driver to create rather than the db object determining its own connection driver to use. This is true also for just lumping everything in a single class per db type. Surely it must be possible ? Or am I missing something ? I also don't really get the idea of interface and abstract classes ? They don't seem to be any practical use ? Maybe that's me ? Anyway, not really relevant to this post ... Please, please can someone help !! Thanks -- 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
Re: [PHP] PHP5 objects access/instantiation model (correction)
On Wed, 2007-07-11 at 16:46 +0100, Steve Perkins wrote: I guess there are lots of workaround ways. I could write lots of middleman code in generic and use things like __set and __get etc but its lots of extra overhead. I also know I could use extends but that makes the code the wrong way around (MySQL_Driver would have to extend generic), hence the top-level application would have to include code to determine which driver to create rather than the db object determining its own connection driver to use. This is true also for just lumping everything in a single class per db type. You want a factory class that creates an instance of the appropriate driver object. The driver object SHOULD extend the generic class. ?php class DbFactory { function __construct() { // :) } function getConnection( $type, $params ) { if( $type == 'MySQL' ) { return new DB_Driver_MySQL; } else if( $type == 'ODBC' ) { return new DB_Driver_ODBC; } return false; } } class DB_Driver_Generic { public $var1; public $var2; function __construct() { } function runQuery( $query ) { } } class DB_Driver_MySQL extends DB_Driver_Generic { function __construct() { parent::__construct(); } } class DB_Driver_ODBC extends DB_Driver_Generic { function __construct() { parent::__construct(); } } ? Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 objects access/instantiation model (correction)
I also don't really get the idea of interface and abstract classes ? They don't seem to be any practical use ? Maybe that's me ? Anyway, not really relevant to this post ... there is a lot of usefulness in these constructs; look into design patterns. also, there are code libraries already written w/ the abstraction you are trying to develop. im not discouraging you from developing your own, but it may be helpful for you to study some of the other code. check out http://pear.php.net/package/MDB2 http://ez.no/doc/components/view/2007.1/(file)/classtrees_Database.html http://www.onphp.org/doxy/trunk/ -nathan ps. i believe interjinn provides a db layer as well : On 7/11/07, Steve Perkins [EMAIL PROTECTED] wrote: OK, so that came out fairly illegible. Try again: Hi, new to PHP5 (and the forums evidently !) and I have a question about the object model. I want to be able to create a class which is allows abstraction from specifics. So for one example, imagine a generic database connection wrapper which can have multiple drivers depending on the database used. Some of the functionality is generic, some is database specific (mysql_ , odbc_). So: Class MySQL_driver { public prop1 ; public connect() { echo Foo; } public runquery() { echo Foo; } ... } Class ODBC_driver { public prop1 ; public connect() { echo Foo; } public runquery() { echo Foo; } ... } Class generic { public $driver = null ; function __construct($connection_type) { if $this-connection_type = MySQL { $this-driver = new MySQL_Driver ; } else { $this-driver = new ODBC_Driver ; } } // Using the non-generic connect() from the selected driver function authenticate { $this-driver-prop1 = fooey // These references work fine from within // the generic class echo $this-driver-prop1 ; echo $this-driver-function1 ; } // Report non-generic errors from the selected driver function errors { } function debug { } ... } $gen = new generic(MySQL) ; // Instantiate the generic database object, which // determines its own driver $gen-driver-prop1 = fooey // but they fail from here echo $gen-driver-prop1 ; echo $gen-driver-function1 ; // this works ok though, so everything is created // correctly $gen-authenticate() ; So I want to access generic functions as $generic-authenticate(), and database specific functions $generic-driver-runquery. This allows the top level code to be able to be completely generic and not know anything about the underlying database. But I can't ! I can't find a way of accessing the encapsulated object (driver) from the instantiator of generic. Is it possible ? I guess there are lots of workaround ways. I could write lots of middleman code in generic and use things like __set and __get etc but its lots of extra overhead. I also know I could use extends but that makes the code the wrong way around (MySQL_Driver would have to extend generic), hence the top-level application would have to include code to determine which driver to create rather than the db object determining its own connection driver to use. This is true also for just lumping everything in a single class per db type. Surely it must be possible ? Or am I missing something ? I also don't really get the idea of interface and abstract classes ? They don't seem to be any practical use ? Maybe that's me ? Anyway, not really relevant to this post ... Please, please can someone help !! Thanks -- 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
Re: [PHP] PHP5 objects access/instantiation model (correction)
On Wed, 2007-07-11 at 12:07 -0400, Nathan Nobbe wrote: I also don't really get the idea of interface and abstract classes ? They don't seem to be any practical use ? Maybe that's me ? Anyway, not really relevant to this post ... there is a lot of usefulness in these constructs; look into design patterns. also, there are code libraries already written w/ the abstraction you are trying to develop. im not discouraging you from developing your own, but it may be helpful for you to study some of the other code. check out http://pear.php.net/package/MDB2 http://ez.no/doc/components/view/2007.1/(file)/classtrees_Database.html http://www.onphp.org/doxy/trunk/ -nathan ps. i believe interjinn provides a db layer as well : It does :) It was especially important in PHP4 since there was no PDO as there is now in PHP5. Not that I'm particularly familiar with PDO (maybe it has deficiencies?). Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 objects access/instantiation model (correction)
some ideas about class design: 1. properties should normally (read almost always) be private. 2. the apps interface to the DB [connection] is via the 'generic' class, the app should have to know nothing about the drive object and should have no direct access to it. 3. use an interface definition for your drivers (so they all share a common set of method ... a common interface ;-)) this leaves you with the problem of wanting to write as little boilerplate code for making the functionality each driver class implements available via the 'generic' class. I would suggest either a few simple functions like so: class DB { function query() { $args = func_get_args(); return call_user_func_array(array($this-driver, __FUNCTION__), $args); } } which you can simplify into something like: class DB { function __call($meth, $args) { $func = array($this-driver, $meth) if (!is_callable($func)) throw new Exception('undefined interface: '.__CLASS__.'::'$meth); return call_user_func_array($func, $args); } } just an idea :-) ... this seems to me to be something along the decorator pattern, you could choose to do something along the lines of the factory pattern, where by your factory returns a 'driver' object which your application uses (not caring what class of driver it is) ... this would also require that your driver classes share a common interface (actually using a interface definition to enforce it is a seperate issue). an interface example: interface DBDriver { function query($sql, $args); function commit($id); function rollback($id); } class MySQL_DBDriver implements DBDriver { function query($sql, $args) { return mysql_query($sql, $args); } function commit($id); { return true; } function rollback($id); { return true; } } Steve Perkins wrote: // but they fail from here echo $gen-driver-prop1 ; echo $gen-driver-function1 ; what fails exactly? what is the error? // this works ok though, so everything is created // correctly $gen-authenticate() ; PS. I would hazard a guess and say the generic class is not very generic - it's quite specifically a 'database' class, it is an 'abstract' class (not in the php syntax sense) in that the DBMS specifics are hidden away in helper/plugin classes. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 objects access/instantiation model (correction)
Robert, I looked at your code in InterJinn a couple of times; i havent gone over all of it mind you but it looks pretty sweet. have you had a look at any of the other frameworks i mentioned earlier in this thread? ez components, onPHP, and now there is a new one ive found (in recent thread) Radicore. i really like the xsl approach for templates. All, also, more on topic; there are many different ways to use interfaces and abstract classes in many different design patterns. they all have purpose, pros and cons. take for instance factory method and abstract factory; where the former uses inheritance the later uses composition. the former can produce only a single class of products, but the abstract base class rarely needs revision; whereas the later can produce sets of related product classes; yet every time a new product class is needed or deprecated the abstract factory [interface] needs revision. Steve, you might also check out http://www.phppatterns.com/docs/start i dont think its been maintained in a while, but its a great place to start. also, i think PDO is pretty sweet, but really its only the base of a strong db abstraction layer, such as what youll find in ez components. -nathan ps. i cant decide if i should build my own db layer around pdo or go for a pre-built one from an aforementioned framework; only time will tell : On 7/11/07, Jochem Maas [EMAIL PROTECTED] wrote: some ideas about class design: 1. properties should normally (read almost always) be private. 2. the apps interface to the DB [connection] is via the 'generic' class, the app should have to know nothing about the drive object and should have no direct access to it. 3. use an interface definition for your drivers (so they all share a common set of method ... a common interface ;-)) this leaves you with the problem of wanting to write as little boilerplate code for making the functionality each driver class implements available via the 'generic' class. I would suggest either a few simple functions like so: class DB { function query() { $args = func_get_args(); return call_user_func_array(array($this-driver, __FUNCTION__), $args); } } which you can simplify into something like: class DB { function __call($meth, $args) { $func = array($this-driver, $meth) if (!is_callable($func)) throw new Exception('undefined interface: '.__CLASS__.'::'$meth); return call_user_func_array($func, $args); } } just an idea :-) ... this seems to me to be something along the decorator pattern, you could choose to do something along the lines of the factory pattern, where by your factory returns a 'driver' object which your application uses (not caring what class of driver it is) ... this would also require that your driver classes share a common interface (actually using a interface definition to enforce it is a seperate issue). an interface example: interface DBDriver { function query($sql, $args); function commit($id); function rollback($id); } class MySQL_DBDriver implements DBDriver { function query($sql, $args) { return mysql_query($sql, $args); } function commit($id); { return true; } function rollback($id); { return true; } } Steve Perkins wrote: // but they fail from here echo $gen-driver-prop1 ; echo $gen-driver-function1 ; what fails exactly? what is the error? // this works ok though, so everything is created // correctly $gen-authenticate() ; PS. I would hazard a guess and say the generic class is not very generic - it's quite specifically a 'database' class, it is an 'abstract' class (not in the php syntax sense) in that the DBMS specifics are hidden away in helper/plugin classes. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 objects access/instantiation model (correction)
On Wed, 2007-07-11 at 12:50 -0400, Nathan Nobbe wrote: Robert, I looked at your code in InterJinn a couple of times; i havent gone over all of it mind you but it looks pretty sweet. It's very different in many respects from other styles of coding. It's an MVC approach for the most part but the way libraries are accessed is different than what I've seen elsewhere. In general class names are only used in two places... when extending a class, and in the registration of a class to a service. Instead classes are registered as services/libraries and instances are retrieved by a general factory mechanism that returns the instance based on the service/library name. In this way almost all aspects of the framework can be overloaded, even if they are core features, without ever touching the core code itself or ever having to change class references within your code since you can just register a different class for the service and all existing uses of that service will now use the newly registered version. This was very useful even before PHP5 got autoload (and even still IMHO) because the loader would load the class's code on an as requested basis. have you had a look at any of the other frameworks i mentioned earlier in this thread? ez components I work with a version of ez components on almost a daily basis (pre-existing CMS that a client had set up) ... it makes me scream because their template engine is godawful because it uses a block approach that requires changing the PHP code if you move blocks out of registered nestings. It's absolutely horrible. The code for the classes is generally disgusting also, but that's just my opinion. Fortunately, I was allowed to hook in InterJinn as needed and so new stuff uses the ez components framework bu generally punts the work to InterJinn modules / services / and templates. We've found run time speed to be much greater for those modules and the maintainability of the content is much, much, easier. , onPHP, and now there is a new one ive found (in recent thread) Radicore. i really like the xsl approach for templates. XSL is nice, but it's complex for the average Joe content developer. When I created InterJinn I wanted something with similar capabilities but without the restriction of well-formed-ness for the HTML content in general (so that existing content could still be adapted with minimal disruption - my new site is XHTML strict). So I created custom tags that can wrap well-formed or not-so-well formed content and process as necessary. Generally speaking though the template engine isn't in any way limited to just custom tags, it can include anything since it's pluggable and extendable. Also, unlike most other template engines, TemplateJinn compiles to the actual PHP code the web server loads, so there's no run-time hit, and in fact, there can be a run time bonus on some aspects. For instance headers, footers, etc, etc can be punted to separate templates but at compile time they are brought together to create the final page. That's not to say TemplateJinn can't be used at run-time, it can be, and it is in the case of the ez components hooking since ezcomponents uses a front end loader. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 objects access/instantiation model (correction)
You probably ought to have: class mysql_driver extends generic_driver { } Seems like that would be the most reasonable OOP model, imho. That said, I suspect that if you do something like: $driver = $this-driver; You then may be able to access the driver-specific data using $driver-propl; etc. On Wed, July 11, 2007 10:46 am, Steve Perkins wrote: OK, so that came out fairly illegible. Try again: Hi, new to PHP5 (and the forums evidently !) and I have a question about the object model. I want to be able to create a class which is allows abstraction from specifics. So for one example, imagine a generic database connection wrapper which can have multiple drivers depending on the database used. Some of the functionality is generic, some is database specific (mysql_ , odbc_). So: Class MySQL_driver { public prop1 ; public connect() { echo Foo; } public runquery() { echo Foo; } ... } Class ODBC_driver { public prop1 ; public connect() { echo Foo; } public runquery() { echo Foo; } ... } Class generic { public $driver = null ; function __construct($connection_type) { if $this-connection_type = MySQL { $this-driver = new MySQL_Driver ; } else { $this-driver = new ODBC_Driver ; } } // Using the non-generic connect() from the selected driver function authenticate { $this-driver-prop1 = fooey // These references work fine from within // the generic class echo $this-driver-prop1 ; echo $this-driver-function1 ; } // Report non-generic errors from the selected driver function errors { } function debug { } ... } $gen = new generic(MySQL) ; // Instantiate the generic database object, which // determines its own driver $gen-driver-prop1 = fooey // but they fail from here echo $gen-driver-prop1 ; echo $gen-driver-function1 ; // this works ok though, so everything is created // correctly $gen-authenticate() ; So I want to access generic functions as $generic-authenticate(), and database specific functions $generic-driver-runquery. This allows the top level code to be able to be completely generic and not know anything about the underlying database. But I can't ! I can't find a way of accessing the encapsulated object (driver) from the instantiator of generic. Is it possible ? I guess there are lots of workaround ways. I could write lots of middleman code in generic and use things like __set and __get etc but its lots of extra overhead. I also know I could use extends but that makes the code the wrong way around (MySQL_Driver would have to extend generic), hence the top-level application would have to include code to determine which driver to create rather than the db object determining its own connection driver to use. This is true also for just lumping everything in a single class per db type. Surely it must be possible ? Or am I missing something ? I also don't really get the idea of interface and abstract classes ? They don't seem to be any practical use ? Maybe that's me ? Anyway, not really relevant to this post ... Please, please can someone help !! Thanks -- 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 -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP5 objects access/instantiation model (correction)
Yeah. I've been working on re-writing it using bits from everyone !! It's a good learning process to find out how PHP handles OOP. I thoroughly recommend it, it's the only way to learn. Some things just can't be learnt from the manual! Cheers All. -Original Message- From: Richard Lynch [mailto:[EMAIL PROTECTED] Sent: 11 July 2007 21:29 To: Steve Perkins Cc: php-general@lists.php.net Subject: Re: [PHP] PHP5 objects access/instantiation model (correction) You probably ought to have: class mysql_driver extends generic_driver { } Seems like that would be the most reasonable OOP model, imho. That said, I suspect that if you do something like: $driver = $this-driver; You then may be able to access the driver-specific data using $driver-propl; etc. On Wed, July 11, 2007 10:46 am, Steve Perkins wrote: OK, so that came out fairly illegible. Try again: Hi, new to PHP5 (and the forums evidently !) and I have a question about the object model. I want to be able to create a class which is allows abstraction from specifics. So for one example, imagine a generic database connection wrapper which can have multiple drivers depending on the database used. Some of the functionality is generic, some is database specific (mysql_ , odbc_). So: Class MySQL_driver { public prop1 ; public connect() { echo Foo; } public runquery() { echo Foo; } ... } Class ODBC_driver { public prop1 ; public connect() { echo Foo; } public runquery() { echo Foo; } ... } Class generic { public $driver = null ; function __construct($connection_type) { if $this-connection_type = MySQL { $this-driver = new MySQL_Driver ; } else { $this-driver = new ODBC_Driver ; } } // Using the non-generic connect() from the selected driver function authenticate { $this-driver-prop1 = fooey // These references work fine from within // the generic class echo $this-driver-prop1 ; echo $this-driver-function1 ; } // Report non-generic errors from the selected driver function errors { } function debug { } ... } $gen = new generic(MySQL) ; // Instantiate the generic database object, which // determines its own driver $gen-driver-prop1 = fooey // but they fail from here echo $gen-driver-prop1 ; echo $gen-driver-function1 ; // this works ok though, so everything is created // correctly $gen-authenticate() ; So I want to access generic functions as $generic-authenticate(), and database specific functions $generic-driver-runquery. This allows the top level code to be able to be completely generic and not know anything about the underlying database. But I can't ! I can't find a way of accessing the encapsulated object (driver) from the instantiator of generic. Is it possible ? I guess there are lots of workaround ways. I could write lots of middleman code in generic and use things like __set and __get etc but its lots of extra overhead. I also know I could use extends but that makes the code the wrong way around (MySQL_Driver would have to extend generic), hence the top-level application would have to include code to determine which driver to create rather than the db object determining its own connection driver to use. This is true also for just lumping everything in a single class per db type. Surely it must be possible ? Or am I missing something ? I also don't really get the idea of interface and abstract classes ? They don't seem to be any practical use ? Maybe that's me ? Anyway, not really relevant to this post ... Please, please can someone help !! Thanks -- 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 -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- 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
Re: [PHP] PHP5 TUTORIAL
hello, other interesting articles to give a bird's eye view of new features for php5 http://www.onlamp.com/pub/a/php/2004/07/15/UpgradePHP5.html http://devzone.zend.com/node/view/id/1714 http://www.devshed.com/c/a/PHP/Whats-New-in-PHP-5/ hth. yashesh bhatia. On 6/26/07, Preethi [EMAIL PROTECTED] wrote: Hi, Need to have a kick start on PHP5. Kindly suggest me the good online tutorial for PHP5. Am already working on php4. Need to migrate from php4 to php5. Regards, Preethi. Extn No: 4099 Some of the greatest science comes from those unaware of established rules and theories. -- Go Pre http://www2.localaccess.com/rlalonde/pre.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP5 TUTORIAL
BlankHi, Need to have a kick start on PHP5. Kindly suggest me the good online tutorial for PHP5. Am already working on php4. Need to migrate from php4 to php5. Regards, Preethi. Extn No: 4099 Some of the greatest science comes from those unaware of established rules and theories.
Re: [PHP] PHP5 TUTORIAL
Hi Preethi Kindly suggest me the good online tutorial for PHP5. Am already working on php4. Need to migrate from php4 to php5. i think this is very important for OOP: http://www.php.net/manual/en/language.oop5.php and this one: http://www.php.net/manual/en/language.exceptions.php regards, Hagen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 TUTORIAL
if you want to spend a little i would recommend this book from php|arch http://www.phparch.com/shop_product.php?itemid=135 -nathan On 6/26/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi Preethi Kindly suggest me the good online tutorial for PHP5. Am already working on php4. Need to migrate from php4 to php5. i think this is very important for OOP: http://www.php.net/manual/en/language.oop5.php and this one: http://www.php.net/manual/en/language.exceptions.php regards, Hagen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 or PHP4 this is the question
On Saturday 09 June 2007, Robert Cummings wrote: On Sat, 2007-06-09 at 19:18 -0500, Larry Garfield wrote: You should get a new server that supports PHP 5.2.1. PHP 4 is dead. Must be a zombie then because I see it running almost EVERYWHERE. Yep, it is. PHP 4 is trying to eat your brains. BRINS! -- Larry Garfield AIM: LOLG42 [EMAIL PROTECTED] ICQ: 6817012 If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it. -- Thomas Jefferson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 or PHP4 this is the question
On 6/10/07, Larry Garfield [EMAIL PROTECTED] wrote: On Saturday 09 June 2007, Robert Cummings wrote: On Sat, 2007-06-09 at 19:18 -0500, Larry Garfield wrote: You should get a new server that supports PHP 5.2.1. PHP 4 is dead. Must be a zombie then because I see it running almost EVERYWHERE. Yep, it is. PHP 4 is trying to eat your brains. BRINS! PHP4 Zombie attack!! -- Larry Garfield AIM: LOLG42 [EMAIL PROTECTED] ICQ: 6817012 If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it. -- Thomas Jefferson -- 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
Re: [PHP] PHP5 or PHP4 this is the question
On Sun, 2007-06-10 at 11:01 -0500, Larry Garfield wrote: On Saturday 09 June 2007, Robert Cummings wrote: On Sat, 2007-06-09 at 19:18 -0500, Larry Garfield wrote: You should get a new server that supports PHP 5.2.1. PHP 4 is dead. Must be a zombie then because I see it running almost EVERYWHERE. Yep, it is. PHP 4 is trying to eat your brains. BRINS! Not mine... I'm a level 60 Necromancer :) Cheers, Rob. -- .. | 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. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 or PHP4 this is the question
At 10:05 PM -0400 6/9/07, Robert Cummings wrote: On Sat, 2007-06-09 at 19:18 -0500, Larry Garfield wrote: You should get a new server that supports PHP 5.2.1. PHP 4 is dead. Must be a zombie then because I see it running almost EVERYWHERE. Cheers, Rob. Rob: You raise an excellent and obvious point. There are significant differences between 4 and 5 and if we are to code for clients who are still in 4, then using 5 routines won't work. For those clients, we must either dumb-down or get them to smarten-up. Considering that I never get anyone to do anything, I know where that leaves me. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 or PHP4 this is the question
On Sunday 10 June 2007, tedd wrote: At 10:05 PM -0400 6/9/07, Robert Cummings wrote: On Sat, 2007-06-09 at 19:18 -0500, Larry Garfield wrote: You should get a new server that supports PHP 5.2.1. PHP 4 is dead. Must be a zombie then because I see it running almost EVERYWHERE. Cheers, Rob. Rob: You raise an excellent and obvious point. There are significant differences between 4 and 5 and if we are to code for clients who are still in 4, then using 5 routines won't work. For those clients, we must either dumb-down or get them to smarten-up. Considering that I never get anyone to do anything, I know where that leaves me. Actually, several open source projects are trying to band together to push for PHP 5 compatibility. We're still in early stages, but if you work on an open source project and are interested in joining together on this, contact me off list. :-) -- Larry Garfield AIM: LOLG42 [EMAIL PROTECTED] ICQ: 6817012 If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it. -- Thomas Jefferson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP5 or PHP4 this is the question
Hi all, After designing and testing my web pages in PHP 5.2.1 I learned that our web server has PHP 4.4.1 and I have to rollback to version 4 ! . There is no OO implementation like classes or objects in my scripts but every page has some queries the question is : will my scripts work in PHP 4 ? or should I re-write all of them? or will it affect the speed of queries? Thank you - Be a better Globetrotter. Get better travel answers from someone who knows. Yahoo! Answers - Check it out.
Re: [PHP] PHP5 or PHP4 this is the question
On Sat, 2007-06-09 at 11:59 -0700, elk dolk wrote: Hi all, After designing and testing my web pages in PHP 5.2.1 I learned that our web server has PHP 4.4.1 and I have to rollback to version 4 ! . There is no OO implementation like classes or objects in my scripts but every page has some queries the question is : will my scripts work in PHP 4 ? or should I re-write all of them? or will it affect the speed of queries? Should work mostly fine. PHP5 mostly brought OOP features to the table. Since you say you didn't use any OOP, then you just need to be wary of the odd PHP5 only function. Cheers, Rob. -- .. | 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. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 or PHP4 this is the question
On Sat, June 9, 2007 1:59 pm, elk dolk wrote: After designing and testing my web pages in PHP 5.2.1 I learned that our web server has PHP 4.4.1 and I have to rollback to version 4 ! . There is no OO implementation like classes or objects in my scripts but every page has some queries the question is : will my scripts work in PHP 4 ? or should I re-write all of them? or will it affect the speed of queries? If there's no OO and you haven't used simpleXML or the fancy SOAP stuff, then it will probably work fine in PHP 4. Actually, it will probably work fine in PHP 3 too, for that matter... :-) The queries working or not working is dependent on the database version, not PHP. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 or PHP4 this is the question
On 6/9/07, elk dolk [EMAIL PROTECTED] wrote: Hi all, After designing and testing my web pages in PHP 5.2.1 I learned that our web server has PHP 4.4.1 and I have to rollback to version 4 ! . There is no OO implementation like classes or objects in my scripts but every page has some queries the question is : will my scripts work in PHP 4 ? or should I re-write all of them? or will it affect the speed of queries? Thank you Put them on the site, see if it's missing functions, if so, go to the manual page of the function and take a look at the comments, mostly there's a PHP4 replacer described. Tijnema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 or PHP4 this is the question
At 3:27 PM -0400 6/9/07, Robert Cummings wrote: On Sat, 2007-06-09 at 11:59 -0700, elk dolk wrote: Hi all, After designing and testing my web pages in PHP 5.2.1 I learned that our web server has PHP 4.4.1 and I have to rollback to version 4 ! . There is no OO implementation like classes or objects in my scripts but every page has some queries the question is : will my scripts work in PHP 4 ? or should I re-write all of them? or will it affect the speed of queries? Should work mostly fine. PHP5 mostly brought OOP features to the table. Since you say you didn't use any OOP, then you just need to be wary of the odd PHP5 only function. Cheers, Rob. My host just upgraded from php 4 to php 5 and while I appreciate the upgrade, now my really exotic functions like date() throw errors -- duh! Plus, none of my passwords work anymore, so I can't fit anything -- duh, again! Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 or PHP4 this is the question
You should get a new server that supports PHP 5.2.1. PHP 4 is dead. It hasn't had a non-security/bug release in years. PHP 5 is 3 years old. The one and only reason to care about PHP 4 at this point is if you're writing something that has to run on any possible cheap shared web host, and even many of those are starting to move to PHP 5.2. If you're on a shared host, get a new shared host that supports PHP 5.2. If you're running your own server, install PHP 5.2. If your server's sysadmin won't let you upgrade to 5.2 or won't give yo a new box on which to put 5.2, then get a new sysadmin because he is going to suffocate your development. As to the liklihood of portability, it depends on what you've actually done. Anything interesting with OO starts in PHP 5, but you said you're not using that. Are you passing objects (even stdClass objects)? That changes. Are you using any of the newer array handling functions, like array_combine? PHP 5 added a lot of them, many of which can be implemented in user-space using PEAR::PHP_Compat. There are more subtle differences, too. So it's quite possible that if you're not doing anything exotic you can downgrade your script without too much trouble. You're still better off doing the Internet a favor and removing one more PHP 4 server from existence. It will make your life easier in the long run. On Saturday 09 June 2007, elk dolk wrote: Hi all, After designing and testing my web pages in PHP 5.2.1 I learned that our web server has PHP 4.4.1 and I have to rollback to version 4 ! . There is no OO implementation like classes or objects in my scripts but every page has some queries the question is : will my scripts work in PHP 4 ? or should I re-write all of them? or will it affect the speed of queries? Thank you - Be a better Globetrotter. Get better travel answers from someone who knows. Yahoo! Answers - Check it out. -- Larry Garfield AIM: LOLG42 [EMAIL PROTECTED] ICQ: 6817012 If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it. -- Thomas Jefferson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 or PHP4 this is the question
On Sat, 2007-06-09 at 18:10 -0400, tedd wrote: At 3:27 PM -0400 6/9/07, Robert Cummings wrote: On Sat, 2007-06-09 at 11:59 -0700, elk dolk wrote: Hi all, After designing and testing my web pages in PHP 5.2.1 I learned that our web server has PHP 4.4.1 and I have to rollback to version 4 ! . There is no OO implementation like classes or objects in my scripts but every page has some queries the question is : will my scripts work in PHP 4 ? or should I re-write all of them? or will it affect the speed of queries? Should work mostly fine. PHP5 mostly brought OOP features to the table. Since you say you didn't use any OOP, then you just need to be wary of the odd PHP5 only function. Cheers, Rob. My host just upgraded from php 4 to php 5 and while I appreciate the upgrade, now my really exotic functions like date() throw errors -- duh! Plus, none of my passwords work anymore, so I can't fit anything -- duh, again! :( I PHP5 proofed my stuff a long time ago for the inevitable switch. I still code for PHP4 but I keep in mind the differences and make sure it works both ways. Are you getting errors or warnings? Date issues sounds like you need ot set your timezone. Did they also upgrade the MySQL server (password issue sounds like MySQL). Cheers, Rob. -- .. | 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. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 or PHP4 this is the question
On Sat, 2007-06-09 at 19:18 -0500, Larry Garfield wrote: You should get a new server that supports PHP 5.2.1. PHP 4 is dead. Must be a zombie then because I see it running almost EVERYWHERE. Cheers, Rob. -- .. | 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. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 oop question...
Andrei wrote: Hi list, I have a class which I use to parse simple bbcode inside some comments. I noticed on PHP5 that scope of preg_replace function is changed when function is called inside a class. To the point: [CODE] class PHS_editor { ... function parse_content( $str = null ) { $from_arr = array( @\[B\](.*?)\[\/[EMAIL PROTECTED], @\[U\](.*?)\[\/[EMAIL PROTECTED], @\[I\](.*?)\[\/[EMAIL PROTECTED], @\[URL=([^\]]*)\]([^\[]*?)\[\/[EMAIL PROTECTED], @\[IMG=([^\]]*)[EMAIL PROTECTED], @\[QUOTE=([^\]]*)\]([^\[]*?)\[\/[EMAIL PROTECTED] ); $to_arr = array( 'b\1/b', 'u\1/u', 'i\1/i', 'a href=\1 target=_blank\2/a', 'img src=\'.stripslashes( \*$this-get_image_location*( '\\1' ) ).'\ border=\0\', 'table width=\98%\ align=\center\ cellpadding=\1\ cellspacing=\0\ border=\0\ class=\form_type\. tr. td class=\maintext\'.stripslashes( \*$this-remove_mytags*( '\\2' ) ).'/td. /tr. /table' ); if( is_null( $str ) ) $str = $this-editor_content; return preg_replace( $from_arr, $to_arr, str_replace( , nbsp;, nl2br( $str ) ) ); } ... } [/CODE] When it gets to parse [IMG] tags I get Fatal error: Using $this when not in object context in So it seems they changed the scope for preg_replace callback functions. As this function is called inside the method shouldn't it have the scope of the class? Is there a workaround for this? I cannot declare a function get_image_location which will staticly call the method bcuz I use variables from instanced class. How are you trying to use this class? It sounds like you're trying to use the method statically. When a method is called statically it does not have a $this. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 oop question...
Stut wrote: Andrei wrote: Hi list, I have a class which I use to parse simple bbcode inside some comments. I noticed on PHP5 that scope of preg_replace function is changed when function is called inside a class. To the point: [CODE] class PHS_editor { ... function parse_content( $str = null ) { $from_arr = array( @\[B\](.*?)\[\/[EMAIL PROTECTED], @\[U\](.*?)\[\/[EMAIL PROTECTED], @\[I\](.*?)\[\/[EMAIL PROTECTED], @\[URL=([^\]]*)\]([^\[]*?)\[\/[EMAIL PROTECTED], @\[IMG=([^\]]*)[EMAIL PROTECTED], @\[QUOTE=([^\]]*)\]([^\[]*?)\[\/[EMAIL PROTECTED] ); $to_arr = array( 'b\1/b', 'u\1/u', 'i\1/i', 'a href=\1 target=_blank\2/a', 'img src=\'.stripslashes( \*$this-get_image_location*( '\\1' ) ).'\ border=\0\', 'table width=\98%\ align=\center\ cellpadding=\1\ cellspacing=\0\ border=\0\ class=\form_type\. tr. td class=\maintext\'.stripslashes( \*$this-remove_mytags*( '\\2' ) ).'/td. /tr. /table' ); if( is_null( $str ) ) $str = $this-editor_content; return preg_replace( $from_arr, $to_arr, str_replace( , nbsp;, nl2br( $str ) ) ); } ... } [/CODE] When it gets to parse [IMG] tags I get Fatal error: Using $this when not in object context in So it seems they changed the scope for preg_replace callback functions. As this function is called inside the method shouldn't it have the scope of the class? Is there a workaround for this? I cannot declare a function get_image_location which will staticly call the method bcuz I use variables from instanced class. How are you trying to use this class? It sounds like you're trying to use the method statically. When a method is called statically it does not have a $this. -Stut Yes, method was called staticly. Strange tho in php 4 it worked. Thnx for enlighting me with this. Andy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php5 cert
On Fri, May 18, 2007 4:45 pm, Greg Donald wrote: Anyone wanna share their insights into the php5 cert test? The php4 test was pretty simple for me, but that was a couple of years ago. It seems there's quite a bit of new material being covered on the php5 version. I figure with the same number of questions, things had to get more general if anything, right? Didn't take either, but surveyed a half-dozen who took it at php|tek last week... My basic impression was that they threw out a lot of the stupid questions that relied on arcane knowledge or were just plain Bad Code of nasty loops with silly breaks etc. What got added was a lot of OOP stuff and stream stuff and... 'Course, there's more than just one test that they hand out, as I understand it, so there are variations to it, and I had a very very very small sample of people who I chatted with. And none of them know for sure if they passed yet or not, really. :-) I was busy both times the test was being administered, but would probably fail anyway on the new features parts. I'm pretty set in my ways... :-) -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php5 cert
On Sun, May 20, 2007 10:14 am, Danial Rahmanzadeh wrote: are volcan exams really harder than actual php5 exam as phparch asserted? I'm pretty sure after seeing Star Trek: Voyage Home, that Vulcan exams are MUCH harder than the PHP 5 exam. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php5 cert
are volcan exams really harder than actual php5 exam as phparch asserted?
Re: [PHP] php5 cert
Actually I found the real exam harder than the test exam. It may have just been the question set I ended up with, but it was a lot more nitpicky on details that I rarely use in my work. On Sunday 20 May 2007, Danial Rahmanzadeh wrote: are volcan exams really harder than actual php5 exam as phparch asserted? -- Larry Garfield AIM: LOLG42 [EMAIL PROTECTED] ICQ: 6817012 If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it. -- Thomas Jefferson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php5 cert
This one time, at band camp, Greg Donald [EMAIL PROTECTED] wrote: Anyone wanna share their insights into the php5 cert test? As worthless as the php4 cert. Kevin -- Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php5 cert
On 5/19/07, Kevin Waterson [EMAIL PROTECTED] wrote: As worthless as the php4 cert. Mine has been very valuable to me, lots more job interviews and freelance work compared to before I got it. -- Greg Donald http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP5 Static functions called through __call() that don't exist... yet
Hi all, I am building an assertType object using static functions. What I want to keep away from is the following: code public static function assertString($para){ return $answer; }; public static function assertBool($para){ return $answer; }; ... public static function assertArray($para){ return $answer; }; /code What I would like to do is replace this with the following: code if (!class_exists('TypeAssert')) { class TypeAssert { private static $types = array( 'array','bool','float','integer','null','numeric', 'object','resource','scalar','string' ); public static function __call($method,$arguments) { $obj = self::assertStandardTypes($arguments[0]); return $obj-$method; } public static function assertStandardTypes($para) { $r = TypeAssert::getTypesObject(); if (is_array($para))$r-array = true; if (is_bool($para)) $r-bool = true; if (is_float($para))$r-float = true; if (is_integer($para)) $r-integer = true; if (is_null($para)) $r-null = true; if (is_numeric($para)) $r-numeric = true; if (is_object($para)) $r-object = true; if (is_resource($para)) $r-resource = true; if (is_scalar($para)) $r-scalar = true; if (is_string($para)) $r-string = true; return $r; } public static function getTypesObject() { $obj = (object) ''; for ($i = 0; $i count(self::$types); $i++) { $obj-{self::$types[$i]} = (bool) false; } return $obj; } } } echo('pre'); echo(TypeAssert::string('test')); echo('/pre'); /code I don't think this is possible (see http://marc.info/?l=php-generalm=114558851102060w=2 ). But I would LIKE for it to work (currently, the above code doesn't). Anybody have any insight on how I might get this to work? Thanks! -- Jared Farrish Intermediate Web Developer Denton, Tx Abraham Maslow: If the only tool you have is a hammer, you tend to see every problem as a nail. $$
[PHP] php5 cert
Anyone wanna share their insights into the php5 cert test? The php4 test was pretty simple for me, but that was a couple of years ago. It seems there's quite a bit of new material being covered on the php5 version. I figure with the same number of questions, things had to get more general if anything, right? -- Greg Donald http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php5 include() problem
I've got a cgi file in my cgi-bin folder that I'm calling with include(). It worked with php4. My shared host just upgraded to my server to php5.2.0 and the function doesn't work. I can't tell if the problem is a php5 or server configuration [which may have changed during the upgrade] issue. If I call the file as a URL directly, it works. http://www.foo.org/cgi-bin/file.cgi?dir=/testperms=0755 file.cgi chmods the designated directory's permissions. It's a cgi with a php shebang #!/usr/bin/php A simple file_exists() shows the file exists OK, TRUE. I've tried using both syntaxes. include(/home/foo/public_html/cgi-bin/file.cgi?dir=testperms=0755); include(www.foo.org/cgi-bin/file.cgi?dir=testperms=0755); Here is the error msg: Warning: include(/home/foo/public_html/cgi-bin/file.cgi?dir=/testperms=0755) [function.include]: failed to open stream: No such file or directory in /home/foo/public_html/EditPage/cgi_file_test.php on line 15 Bottom line: It appears include() is not working right, for whatever reason. Anyone have any ideas? Thanks, Al -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php5 include() problem
On 5/13/07, Al [EMAIL PROTECTED] wrote: I've got a cgi file in my cgi-bin folder that I'm calling with include(). It worked with php4. My shared host just upgraded to my server to php5.2.0 and the function doesn't work. I can't tell if the problem is a php5 or server configuration [which may have changed during the upgrade] issue. If I call the file as a URL directly, it works. http://www.foo.org/cgi-bin/file.cgi?dir=/testperms=0755 file.cgi chmods the designated directory's permissions. It's a cgi with a php shebang #!/usr/bin/php A simple file_exists() shows the file exists OK, TRUE. I've tried using both syntaxes. include(/home/foo/public_html/cgi-bin/file.cgi?dir=testperms=0755); include(www.foo.org/cgi-bin/file.cgi?dir=testperms=0755); Here is the error msg: Warning: include(/home/foo/public_html/cgi-bin/file.cgi?dir=/testperms=0755) [function.include]: failed to open stream: No such file or directory in /home/foo/public_html/EditPage/cgi_file_test.php on line 15 Bottom line: It appears include() is not working right, for whatever reason. Anyone have any ideas? Thanks, Al What the heck are you trying to do? You want the cgi file to be executed? Or is there PHP code in the cgi file? If you want the first, you should look at exec() or system() or such. If there's PHP code, there's no sense in passing variables to the CGI script, and if you remove the variables it will work. Tijnema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php