php-general Digest 15 Jan 2010 19:18:43 -0000 Issue 6540
php-general Digest 15 Jan 2010 19:18:43 - Issue 6540 Topics (messages 301124 through 301139): Re: To add the final ? or not... 301124 by: Mattias Thorslund 301126 by: Jochem Maas What's the best way to extract HTML out of $var? 301125 by: alexus 301127 by: John Meyer 301132 by: Bruno Fajardo Re: Need Idea to make Backup 301128 by: Jens Geier 301129 by: Jens Geier 301130 by: Jens Geier SMTP Local development to Send email in PHP; Windows Platform/ XP with no IIS 301131 by: Gaurav Kumar 301133 by: Kim Madsen 301134 by: Gaurav Kumar 301135 by: vikash.iitb.gmail.com 301136 by: Richard Quadling 301137 by: Gaurav Kumar Re: strtotime 301138 by: Bob McConnell PHP and javascript 301139 by: Andres Gonzalez Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- Kim Madsen wrote: Mattias Thorslund wrote on 09/01/2010 02:26: A neat thing with pairing every ?php with a ? when mixed in HTML is that these are valid XML processing instructions. If your HTML satisfies XML well-formedness, your PHP document will also be valid XML. Not that I've ever had any need to process my layout templates as XML but anyway. I don't see your argument. PHP generates HTML or XML files. When you're aware of the XML tag of course you make sure the XML file generated is valid. Why would you ever add PHP code to a HTML file (other than for documentation, examples etc.)? It's not much of an argument, just an observation. And the conclusions are disappointing anyway. Certainly, if your script is designed to create XML, you'll make sure that output is valid when executed by PHP. But it is interesting to note that your PHP script file itself might qualify as valid XML under certain circumstances, in which case you could process it with an XML processor. This would let you modify the XML and still keep the PHP part of the file intact. I haven't seen a live example that might benefit from this, but I still find it interesting. The conditions that would need to be met, are that the content outside the ? and ? processing instructions must be well-formed XML, and there are places where the processing instructions aren't expected in XML. This is well-formed XML (and valid PHP): ?xml version=1.0? ?php $var = 'dynamic'; ? root attr=static ?php echo $var content from PHP\n; ? /root ?php //processing instructions can also be located after the XML content ? This is not well-formed XML (processing instruction within a tag). Note however that the output from PHP would be valid XML: ?xml version=1.0? ?php $var = 'dynamic'; ? root ?php echo attr=\$var\; ? ?php echo $var content from PHP\n; ? /root Neither is this (processing instruction within an attribute): ?xml version=1.0? ?php $var = 'dynamic'; ? root attr=?php echo $var; ? ?php echo $var content from PHP\n; ? /root And neither is this (missing opening tag for the root element): ?xml version=1.0? ?php $var = 'dynamic'; ? ?php echo root attr=\$var\\n; ? ?php echo $var content from PHP\n; ? /root A simple way to test this would be to use this: $sxe = new SimpleXMLElement('the_file.php', null, true); echo $sxe-asXML().\n; The inability to insert dynamic content into attributes without breaking the XML (ideas anyone?) does limit the usefulness of this technique, so I guess it will just remain a curiosity. Cheers, Mattias ---End Message--- ---BeginMessage--- Op 1/14/10 11:37 PM, Kim Madsen schreef: Ashley Sheridan wrote on 14/01/2010 23:30: What is the difference between: ? print hello PHPeople; ?WHITESPACE and ? print hello PHPeople; WHITESPACE Same shit when I look at it, a sloppy developer is what it is :-) -- Kind regards Kim Emax - masterminds.dk Plenty of differences, if you include the first one as a file, the whitespace gets sent to the browser because it is not part of the PHP, and so is assumed to be HTML. Once this happens, the headers have been sent, so you can't use different headers in your script. Hmm... you could be right. I guess I just never made that mistake :-) could be right? that implies you don't know and didn't bother to test it. I'd postulate that is sloppy. In another post you mention your reliance on your favorite editor - relying blindly on your editor to 'do the right thing' could also be considered sloppy (no tool is perfect all of the time). pretty much every php dev has run into the issue of header() calls failing due to whitespace, it's almost a rite of passage - I'd only call it a mistake if you don't bother to test your code to the extent that you actually get
[PHP] SMTP Local development to Send email in PHP; Windows Platform/ XP with no IIS
Hi All, Ash, Angelo, Any ideas how to send an email in PHP on windows platform/xp on local development machine. System Configuration PHP 5.2 Apache 2 No ISS NO SMTP Any trusted SMTP software to install on local development machine and how to set it up with php to send an email? Also just providing the SMTP server details in php.ini will not work for me as this requires authentication/credentials etc.. Thanks, Gaurav Kumar blog.oswebstudio.com
Re: [PHP] What's the best way to extract HTML out of $var?
2010/1/15 alexus ale...@gmail.com: What's the best way to extract HTML out of $var? example of $var $var = a href=http://http://stackoverflow.com/Stack Overflow/a I want $var2 = http://starckoverflow.com/; example: preg_match(); what else? Hi, If you simply wants to remove all tags from the string, try using the strip_tags function (http://php.net/strip_tags). -- http://alexus.org/ -- 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] SMTP Local development to Send email in PHP; Windows Platform/ XP with no IIS
Hi Gaurav Gaurav Kumar wrote on 15/01/2010 09:54: NO SMTP Any trusted SMTP software to install on local development machine and how to set it up with php to send an email? Also just providing the SMTP server details in php.ini will not work for me as this requires authentication/credentials etc.. Get PHPmailer and make a gmail account that you connect to and mail through. -- Kind regards Kim Emax - masterminds.dk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SMTP Local development to Send email in PHP; Windows Platform/ XP with no IIS
Sorry Kim, don't want to use phpmailer script or manually setting user accounts u/p in the script. On Fri, Jan 15, 2010 at 5:23 PM, Kim Madsen php@emax.dk wrote: Hi Gaurav Gaurav Kumar wrote on 15/01/2010 09:54: NO SMTP Any trusted SMTP software to install on local development machine and how to set it up with php to send an email? Also just providing the SMTP server details in php.ini will not work for me as this requires authentication/credentials etc.. Get PHPmailer and make a gmail account that you connect to and mail through. -- Kind regards Kim Emax - masterminds.dk
Re: [PHP] SMTP Local development to Send email in PHP; Windows Platform/ XP with no IIS
You can install any smtp server on your windows machine and the mail() will work with default settings. You can check this out: http://www.softstack.com/freesmtp.html Thanks, Vikash Kumar http://vika.sh On Fri, Jan 15, 2010 at 5:30 PM, Gaurav Kumar kumargauravjuke...@gmail.comwrote: Sorry Kim, don't want to use phpmailer script or manually setting user accounts u/p in the script. On Fri, Jan 15, 2010 at 5:23 PM, Kim Madsen php@emax.dk wrote: Hi Gaurav Gaurav Kumar wrote on 15/01/2010 09:54: NO SMTP Any trusted SMTP software to install on local development machine and how to set it up with php to send an email? Also just providing the SMTP server details in php.ini will not work for me as this requires authentication/credentials etc.. Get PHPmailer and make a gmail account that you connect to and mail through. -- Kind regards Kim Emax - masterminds.dk
Re: [PHP] SMTP Local development to Send email in PHP; Windows Platform/ XP with no IIS
2010/1/15 vikash.i...@gmail.com: You can install any smtp server on your windows machine and the mail() will work with default settings. You can check this out: http://www.softstack.com/freesmtp.html Thanks, Vikash Kumar http://vika.sh On Fri, Jan 15, 2010 at 5:30 PM, Gaurav Kumar kumargauravjuke...@gmail.comwrote: Sorry Kim, don't want to use phpmailer script or manually setting user accounts u/p in the script. On Fri, Jan 15, 2010 at 5:23 PM, Kim Madsen php@emax.dk wrote: Hi Gaurav Gaurav Kumar wrote on 15/01/2010 09:54: NO SMTP Any trusted SMTP software to install on local development machine and how to set it up with php to send an email? Also just providing the SMTP server details in php.ini will not work for me as this requires authentication/credentials etc.. Get PHPmailer and make a gmail account that you connect to and mail through. -- Kind regards Kim Emax - masterminds.dk You only need a local SMTP server if you want to hold and relay mail. If you want to send mail directly to the recipients SMTP server you can do that with standard PHP. getmxrr() is your friend here. You provide it with the domain of the recipient and you get back the SMTP server(s) associated with that domain. Now, you can send the message to THEIR smtp server ... ini_set('SMTP', ); where is one of the servers returned from getmxrr(). No authentication required. -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SMTP Local development to Send email in PHP; Windows Platform/ XP with no IIS
Hi Richard, The problem is that if I am using any open source software or any other pre-built software then I will not be able to manage through ini_set. Also http://www.softstack.com/freesmtp.html which vikash mentioned works through outlook settings. Anyways the below will help- http://php.net/manual/en/ref.mail.php http://glob.com.au/sendmail/ Thanks, Gaurav Kumar blog.oswebstudio.com On Fri, Jan 15, 2010 at 6:21 PM, Richard Quadling rquadl...@googlemail.comwrote: 2010/1/15 vikash.i...@gmail.com: You can install any smtp server on your windows machine and the mail() will work with default settings. You can check this out: http://www.softstack.com/freesmtp.html Thanks, Vikash Kumar http://vika.sh On Fri, Jan 15, 2010 at 5:30 PM, Gaurav Kumar kumargauravjuke...@gmail.comwrote: Sorry Kim, don't want to use phpmailer script or manually setting user accounts u/p in the script. On Fri, Jan 15, 2010 at 5:23 PM, Kim Madsen php@emax.dk wrote: Hi Gaurav Gaurav Kumar wrote on 15/01/2010 09:54: NO SMTP Any trusted SMTP software to install on local development machine and how to set it up with php to send an email? Also just providing the SMTP server details in php.ini will not work for me as this requires authentication/credentials etc.. Get PHPmailer and make a gmail account that you connect to and mail through. -- Kind regards Kim Emax - masterminds.dk You only need a local SMTP server if you want to hold and relay mail. If you want to send mail directly to the recipients SMTP server you can do that with standard PHP. getmxrr() is your friend here. You provide it with the domain of the recipient and you get back the SMTP server(s) associated with that domain. Now, you can send the message to THEIR smtp server ... ini_set('SMTP', ); where is one of the servers returned from getmxrr(). No authentication required. -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling
RE: [PHP] strtotime
There are a variety of starting points available, depending on the environment and application. See the Computer section of http://en.wikipedia.org/wiki/Epoch_%28reference_date%29 for a brief review. Bob McConnell -Original Message- From: haliphax [mailto:halip...@gmail.com] Sent: Thursday, January 14, 2010 4:14 PM To: php-general@lists.php.net Subject: Re: [PHP] strtotime On Thu, Jan 14, 2010 at 2:53 PM, Adam Richardson simples...@gmail.comwrote: I've not read this, but if the first valid date is Jan. 1st, 1970, then passing that date back in the case of errors would lead to ambiguity. Is it a valid date or is it an error. Passing back the date of the day just before (in terms of time, I think it's the second before) the first valid date lets you easily identify an error. Again, I didn't read this anywhere, though, and I could be wrong. Adam On Thu, Jan 14, 2010 at 3:47 PM, Kim Madsen php@emax.dk wrote: Hi guys I have a question: snip Ashley Sheridan wrote on 14/01/2010 19:20: MySQL uses a default -00-00 value for date fields generally, but when converted into a timestamp, the string equates to a false value. In PHP, timestamps are numerical values indicating the seconds since Midnight of the 1st January 1969. As PHP uses loose data typing, false /snip Adam Richardson wrote on 14/01/2010 19:25: snip 2. date returns 1969, because it's not passed a valid timestamp and it works from December 31, 1969 for any invalid date. /snip Why is this? Unixtime starts at January 1st 1970 GMT (see for instance http://php.net/microtime), I've never heard of the other dates you mentioned. My guess is the time, date or GMT is wrong for Johns setup and that's why he get 1969 and not 1970, cause something is seting time in the past Time zones. If I have PHP spit out a date for 0 as a string on my system, it comes back as 18:00 on December 31st, 1969, because I am in the Central time zone. // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP and javascript
How do I call PHP code that will run server side, from javascript code that is running client side? I have a lot of PHP server side code written and working within CodeIgniter. Now, my project has changed and (for reasons unimportant to this discussion) we are now NOT going to use apache and CodeIgniter, but instead, we are going to have to use an http server that does not support PHP internally. But I want to reuse my original PHP code. So I am thinking that I can execute the PHP code via a command line interface using the PHP cli interface instead of the PHP cgi interface. But, I will have to initiate this serversid call via javascript code running on the client. I know...kind of convoluted. But how would one do this if necessary? -Andres -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and javascript
I don't think you can call php cli from client javascript unless you have a wrapper http interface On Fri, Jan 15, 2010 at 2:07 PM, Andres Gonzalez and...@packetstorm.comwrote: How do I call PHP code that will run server side, from javascript code that is running client side? I have a lot of PHP server side code written and working within CodeIgniter. Now, my project has changed and (for reasons unimportant to this discussion) we are now NOT going to use apache and CodeIgniter, but instead, we are going to have to use an http server that does not support PHP internally. But I want to reuse my original PHP code. So I am thinking that I can execute the PHP code via a command line interface using the PHP cli interface instead of the PHP cgi interface. But, I will have to initiate this serversid call via javascript code running on the client. I know...kind of convoluted. But how would one do this if necessary? -Andres -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and javascript
On Fri, 2010-01-15 at 14:07 -0500, Andres Gonzalez wrote: How do I call PHP code that will run server side, from javascript code that is running client side? I have a lot of PHP server side code written and working within CodeIgniter. Now, my project has changed and (for reasons unimportant to this discussion) we are now NOT going to use apache and CodeIgniter, but instead, we are going to have to use an http server that does not support PHP internally. But I want to reuse my original PHP code. So I am thinking that I can execute the PHP code via a command line interface using the PHP cli interface instead of the PHP cgi interface. But, I will have to initiate this serversid call via javascript code running on the client. I know...kind of convoluted. But how would one do this if necessary? -Andres I wouldn't recommend doing it this way at all. What you'd essentially need, is Javascript make an AJAX request to a server script, which would then call your PHP shell script, which would then return data to the [other language] server script, that responds back to the Javascript on the browser. What sort of server will you be using that you can' support PHP on it? PHP runs on most web servers out there, and will happily run alongside other language modules on a single server. Who's making the decisions about the new server? Someone really needs to explain to him/her that it's a massive project converting a website from one language to another (I've had to convert a large ColdFusion one to PHP before, so I know) and it will probably cost more in the long term to convert than might be saved on whatever server 'deal' they're getting. Thanks, Ash http://www.ashleysheridan.co.uk
[PHP] mysql_real_escape_string(0xffffffff) yields -1
The subject line says it all: mysql_real_escape_string(0x) yields -1 What's up with that? Is there some way to convince mysql_real_escape_string to use BIGINT? I guess I'll just PCRE for digits and then pass it in and... But what if somebody passes in some BC Math number?... -- Some people ask for gifts here. I just want you to buy an Indie CD for yourself: http://cdbaby.com/search/from/lynch -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_real_escape_string(0xffffffff) yields -1
Richard Lynch wrote: The subject line says it all: mysql_real_escape_string(0x) yields -1 What's up with that? Is there some way to convince mysql_real_escape_string to use BIGINT? I guess I'll just PCRE for digits and then pass it in and... But what if somebody passes in some BC Math number?... Is this a 32 or 64 bit system? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP 5.3 shared hosting
Hi, I've developed a framework that requires PHP 5.3 (it takes a more functional approach.) I'm hosting my own apps on a dedicated server running cpanel (thanks to their recent upgrade.) However, for client work I prefer not to personally host the websites. I've been contacting hosts about their shared hosting options, and I've only found a couple that accommodate PHP 5.3 so far. Anybody have recommendations for shared hosting providers that are supporting php 5.3 (many of the smaller sites I'm working with don't merit a VPS?) Thank you very much for your help, Adam -- Nephtali: PHP web framework that functions beautifully http://nephtaliproject.com
Re: [PHP] PHP 5.3 shared hosting
Adam Richardson wrote: Hi, I've developed a framework that requires PHP 5.3 (it takes a more functional approach.) I'm hosting my own apps on a dedicated server running cpanel (thanks to their recent upgrade.) However, for client work I prefer not to personally host the websites. I've been contacting hosts about their shared hosting options, and I've only found a couple that accommodate PHP 5.3 so far. Anybody have recommendations for shared hosting providers that are supporting php 5.3 (many of the smaller sites I'm working with don't merit a VPS?) Thank you very much for your help, Adam I would suggest pointing your clients at something like linode that allows them to run whatever they hell they want to run. I'm running CentOS 5.x w/ php 5.2.12 for example. I need to update them, but if you want, here are some php 5.3 src.rpm's that can be used to build php 5.3 on a CentOS / RHEL 5.x system - http://www.clfsrpm.net/php/ Running a xen instance is a lot nicer than shared hosting, and not really that expensive, and is really preferable to shared hosting. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SMTP Local development to Send email in PHP; Windows Platform/ XP with no IIS
Hi, Also http://www.softstack.com/freesmtp.html which vikash mentioned works through outlook settings. Anyways the below will help- http://php.net/manual/en/ref.mail.php http://glob.com.au/sendmail/ Personally, I always found hMailServer to be perfectly reliable as a relay on Windows - just install it and SMTP to localhost - nothing more, nothing less. Andy