php-general Digest 16 Oct 2009 15:46:12 -0000 Issue 6393

Topics (messages 298903 through 298918):

Re: Need unrounded precision
        298903 by: Kim Madsen

Re: security/deployment issue
        298904 by: hessiess.hessiess.com

Re: Header problem - "solved"
        298905 by: Kim Madsen

Re: Built-in Debugging
        298906 by: Andrea Giammarchi
        298908 by: Al
        298909 by: Bob McConnell
        298910 by: Al
        298911 by: Ashley Sheridan
        298912 by: Al
        298913 by: Bob McConnell
        298914 by: Robert Cummings
        298915 by: David Murphy

XSLTProcessor: need interface to libxslt´s xsltDocLoaderFunc
        298907 by: Felix Siglreithmaier

How to Delete the parent node, and child nodes/leafs for a db/tbl in php
        298916 by: bruce
        298917 by: Ashley Sheridan

How to pronounce PHP code over the phone?
        298918 by: Dotan Cohen

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


----------------------------------------------------------------------
--- Begin Message ---
Hello

Andre Dubuc wrote on 2010-01-02 02:20:
Hi,

I need to extract the first digit after the decimal point from a number such as 28.56018, which should be '5'.

Since no one came up with the simple solution:

$num = "28.56018";
ereg("^[0-9]+\.([0-9]){1}", trim($num), $regs);
if($regs[1])
  $digit = $regs[1];
else
  print "no digit found";

--
Kind regards
Kim Emax


--- End Message ---
--- Begin Message ---
>> Rsync should work fine, but personally I like to see exactly which
>> changes are being deployed especially when deploying to production.
>> While I realise this recommendation is not Open Source software, I
>> have found it to be an excellent piece of software for this task. I
>> use Beyond Compare which has the ability to connect over SFTP or SCP
>> as well as regular FTP. It allows you to 'diff' the files as you go
>> and view exact changes and you can transfer only the changes you want
>> or whole files if you choose to. I would not be surprised if an Open
>> Source equivalent exists.
>
> What about SVN? you can do a svn export. Or you can have a working
> copy for production too.
> Just dont forget to deny access to .svn in your webserver.
> Here are directives for Apache:
>
> <Directory ~ "^(.*/)?\.svn/?">
>     Order allow,deny
>     Deny from all
> </Directory>
>

I do exactly this, its handy to be able to check out the latest version of
a website, make some changes and commit it again, while having acsess to
the complete revision history, from absolutely anywhere.

SVN works over HTTPS, so can go straight through most firewalls without
anyone noticing and it also does data transmissions (like RSync) which can
be a LOT faster than re uploading the whole file with SFTP etc.

There are some security issues in a shared hosting environment though, if
you use a commit hook to update the web root on commit using a file:///
URL anyone on the server could check out / commit files from the
repository. As of right now the only work around that I can think of for
this would be to run two apches at the same time, one for SVN, and one for
the main HTTP server which is chrooted to block access to the SVN repos
and have the non chrooted server revere proxy connections to the chrooted
one.


--- End Message ---
--- Begin Message ---
Andrea Giammarchi wrote on 2009-10-05 18:26:

 > There's a useful function called headers_sent() which checks to see if
 > the headers have already been sent to the browser. This might be a good
 > place to throw into your code at various points to check and see if
 > something is being written which you don't expect.

true, check that as well, moreover, you talked about utf-8, well, if the BOM is automatically added, it can cause lots of problems ... still, only if you sent whatever to the output before the download.

I've tried a bunch of things, including link to index.php and as first thing check if the request is a zipfile, then throw a zip header, readfile the file then exit the code. Nothing helped. So I figured it could be a latin-1 / utf-8 problem and tried to post to a fresh new page (donwload_zip.php) instead, where I was sure the terminal and Vi was set to use latin-1, then it worked.

It's still not the ultimate solution as we wanted the zipfile to be created on the fly in memory in order not to have to delete files afterwards and to be sure that only allowed users can fetch the files (of course you can always put the zipfiles outside webscope, but still...)

--
Kind regards
Kim Emax

--- End Message ---
--- Begin Message ---
Specially suited for Ajax interaction, you may be interested into Formaldehyde:
http://code.google.com/p/formaldehyde/

Regards

> Date: Thu, 15 Oct 2009 17:39:14 -0700
> From: xwis...@yahoo.com
> To: php-gene...@lists.php.net
> Subject: [PHP] Built-in Debugging
> 
> Hello,
> 
> Will be ever see built-in debugging features for PHP?
> 
> I know there's xdebug but it's sometimes difficult to get it working. I'm 
> hoping that PHP will one day have integrated debugging features that can be 
> easily enabled or disabled:
> 
> <?php
> 
> enable_debug(true);
> debug_console("Hello world!'); // sends an output to the console of the 
> debugger.
> 
> 
> ?>
> 
                                          
_________________________________________________________________
Keep your friends updated—even when you’re not signed in.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_5:092010

--- End Message ---
--- Begin Message ---


Raymond Irving wrote:
Hello,


Will be ever see built-in debugging features for PHP?

I kjnow there's xdebug but it's sometimes difficult to get it working. I'm 
hopoing that PHP will one day have intgrated debuging features that can be 
easily enabled or disabled:

<?php

enable_debug(true);

debug_console("Hello world!'); // sends an output to the console of the 
debugger.


?>


Personally, I've found that turning on "error_reporting(E_ALL)", debug_backtrace() and debug_print_backtrace() quite adequate for most situations.
--- End Message ---
--- Begin Message ---
From: Raymond Irving

> Will be ever see built-in debugging features for PHP?

I do not expect there would be. Debuggers are more likely to be provided
by the IDE. For example, in MS-Windows, Visual Studio is the IDE and can
include any of several compilers. It also includes the debugger, and
uses the same front end for all languages. Of course, Microsoft has it
much easier since they only support one hardware platform (x86) and one
OS. Unlike the rest of the world where tools are more likely to be
portable.

For an IDE with debug capabilities, try NetBeans. I am sure there are
others, but that is the only one I have actually looked at.

Bob McConnell

--- End Message ---
--- Begin Message ---


Bob McConnell wrote:
From: Raymond Irving

Will be ever see built-in debugging features for PHP?

I do not expect there would be. Debuggers are more likely to be provided
by the IDE. For example, in MS-Windows, Visual Studio is the IDE and can
include any of several compilers. It also includes the debugger, and
uses the same front end for all languages. Of course, Microsoft has it
much easier since they only support one hardware platform (x86) and one
OS. Unlike the rest of the world where tools are more likely to be
portable.

For an IDE with debug capabilities, try NetBeans. I am sure there are
others, but that is the only one I have actually looked at.

Bob McConnell

phpEdit, a super IDE, has an extensive suite of integrated debug tools.

--- End Message ---
--- Begin Message ---
On Fri, 2009-10-16 at 09:04 -0400, Al wrote:

> 
> Bob McConnell wrote:
> > From: Raymond Irving
> > 
> >> Will be ever see built-in debugging features for PHP?
> > 
> > I do not expect there would be. Debuggers are more likely to be provided
> > by the IDE. For example, in MS-Windows, Visual Studio is the IDE and can
> > include any of several compilers. It also includes the debugger, and
> > uses the same front end for all languages. Of course, Microsoft has it
> > much easier since they only support one hardware platform (x86) and one
> > OS. Unlike the rest of the world where tools are more likely to be
> > portable.
> > 
> > For an IDE with debug capabilities, try NetBeans. I am sure there are
> > others, but that is the only one I have actually looked at.
> > 
> > Bob McConnell
> 
> phpEdit, a super IDE, has an extensive suite of integrated debug tools.
> 


Real coders don't use debugging tools, comments and output statements
are all you need ;)

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---


Ashley Sheridan wrote:
On Fri, 2009-10-16 at 09:04 -0400, Al wrote:

Bob McConnell wrote:
From: Raymond Irving

Will be ever see built-in debugging features for PHP?
I do not expect there would be. Debuggers are more likely to be provided
by the IDE. For example, in MS-Windows, Visual Studio is the IDE and can
include any of several compilers. It also includes the debugger, and
uses the same front end for all languages. Of course, Microsoft has it
much easier since they only support one hardware platform (x86) and one
OS. Unlike the rest of the world where tools are more likely to be
portable.

For an IDE with debug capabilities, try NetBeans. I am sure there are
others, but that is the only one I have actually looked at.

Bob McConnell
phpEdit, a super IDE, has an extensive suite of integrated debug tools.



Real coders don't use debugging tools, comments and output statements
are all you need ;)

Thanks,
Ash
http://www.ashleysheridan.co.uk




I agree with you and that's why I said in my first message "Personally, I've found that turning on "error_reporting(E_ALL)", debug_backtrace() and debug_print_backtrace() quite adequate for most situations."

In fact, I don't recall even using debug_backtrace() and debug_print_backtrace() in the last couple of years.

I script very robust code and it catches damn near all errors itself.

Al.......

--- End Message ---
--- Begin Message ---
From: Ashley Sheridan

> On Fri, 2009-10-16 at 09:04 -0400, Al wrote:
>> Bob McConnell wrote:
>> > From: Raymond Irving
>> > 
>> >> Will be ever see built-in debugging features for PHP?
>> > 
>> > I do not expect there would be. Debuggers are more likely to be
provided
>> > by the IDE. For example, in MS-Windows, Visual Studio is the IDE
and can
>> > include any of several compilers. It also includes the debugger,
and
>> > uses the same front end for all languages. Of course, Microsoft has
it
>> > much easier since they only support one hardware platform (x86) and
one
>> > OS. Unlike the rest of the world where tools are more likely to be
>> > portable.
>> > 
>> > For an IDE with debug capabilities, try NetBeans. I am sure there
are
>> > others, but that is the only one I have actually looked at.
>> > 
>> > Bob McConnell
>> 
>> phpEdit, a super IDE, has an extensive suite of integrated debug
tools.
>> 
> 
> Real coders don't use debugging tools, comments and output statements
> are all you need ;)
> 
> Thanks,
> Ash

No, we simply use debug or ddt to insert machine code directly into
memory. But that tends to get tedious very quickly, so experimenting
with other options is one way to relieve the boredom.

Bob McConnell

--- End Message ---
--- Begin Message ---
Al wrote:

Ashley Sheridan wrote:
On Fri, 2009-10-16 at 09:04 -0400, Al wrote:

Bob McConnell wrote:
From: Raymond Irving

Will be ever see built-in debugging features for PHP?
I do not expect there would be. Debuggers are more likely to be provided
by the IDE. For example, in MS-Windows, Visual Studio is the IDE and can
include any of several compilers. It also includes the debugger, and
uses the same front end for all languages. Of course, Microsoft has it
much easier since they only support one hardware platform (x86) and one
OS. Unlike the rest of the world where tools are more likely to be
portable.

For an IDE with debug capabilities, try NetBeans. I am sure there are
others, but that is the only one I have actually looked at.

Bob McConnell
phpEdit, a super IDE, has an extensive suite of integrated debug tools.


Real coders don't use debugging tools, comments and output statements
are all you need ;)

Thanks,
Ash
http://www.ashleysheridan.co.uk




I agree with you and that's why I said in my first message "Personally, I've found that turning on "error_reporting(E_ALL)", debug_backtrace() and debug_print_backtrace() quite adequate for most situations."

In fact, I don't recall even using debug_backtrace() and debug_print_backtrace() in the last couple of years.

I script very robust code and it catches damn near all errors itself.

I find having a custom error handler that uses debug_backtrace() to produce a limited stack trace very useful for finding errors sometimes.

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

--- End Message ---
--- Begin Message ---
I have to disagree, while   Exception handling and  the like have their
place. Sometimes when you develop you want to stop execution and  look at
your memory stack to make sure you didn't over look something.

Especially if you are relying on someone  else code  and it's not a project
owned 100% by you.


Just my thoughts, they have their place I use  PhpEd, because it facilitates
this nicely and it VERY customizable from a short hand perspective.

-----Original Message-----
From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: Friday, October 16, 2009 8:05 AM
To: Al
Cc: php-gene...@lists.php.net
Subject: Re: [PHP] Built-in Debugging

On Fri, 2009-10-16 at 09:04 -0400, Al wrote:

> 
> Bob McConnell wrote:
> > From: Raymond Irving
> > 
> >> Will be ever see built-in debugging features for PHP?
> > 
> > I do not expect there would be. Debuggers are more likely to be 
> > provided by the IDE. For example, in MS-Windows, Visual Studio is 
> > the IDE and can include any of several compilers. It also includes 
> > the debugger, and uses the same front end for all languages. Of 
> > course, Microsoft has it much easier since they only support one 
> > hardware platform (x86) and one OS. Unlike the rest of the world 
> > where tools are more likely to be portable.
> > 
> > For an IDE with debug capabilities, try NetBeans. I am sure there 
> > are others, but that is the only one I have actually looked at.
> > 
> > Bob McConnell
> 
> phpEdit, a super IDE, has an extensive suite of integrated debug tools.
> 


Real coders don't use debugging tools, comments and output statements are
all you need ;)

Thanks,
Ash
http://www.ashleysheridan.co.uk


No virus found in this outgoing message.
Checked by AVG - www.avg.com
Version: 8.5.421 / Virus Database: 270.14.20/2440 - Release Date: 10/16/09 
06:32:00

--- End Message ---
--- Begin Message ---
Hi,

in the Java Xalan XSLT processor there is an URIResolver object to
resolve URIs used in xsl:include, xsl:import, etc.
http://xml.apache.org/xalan-j/apidocs/javax/xml/transform/class-use/URIResolver.html

With this URIResolver you can comfortably implement your own logic to
load external resources.

A small example how it works in Java, so maybe my problem is easier to
understand:

TransformerFactory.newInstance().setURIResolver(
    new URIResolver() {
     public Source resolve(String href, String base) {
        // all included files are relative to c:\temp
        return new StreamSource(
          new File ("c:\\temp\\"+href));
        }
    });

and so statements like:
<xsl:include href="include.xsl"/>
will include c:\temp\include.xsl



Now my problem is, that i need this functionality in PHP´s XSLTProcessor.

Generally I think libxslt already supports the same functionality with
the xsltDocLoaderFunc:
http://xmlsoft.org/XSLT/html/libxslt-documents.html#XSLTDOCLOADERFUNC

anyone have an idea how to handle that problem?

thanks a lot

--- End Message ---
--- Begin Message ---
Hi.

I've got a situation where I have a couple of tables. The relationship
between the tables is one of parent/child. I'm trying to figure out the best
approach to being able to delete the associated children in the child tbls,
of a given parentID in the parentTBL...

I've checked into various sites/articles on the 'net.. but i'm not sure how
best to accomplish this...

I'm using php as the interface language to the test tbls..

Any pointers/articles/test code (code/schema) would be helpful...

Thanks



--- End Message ---
--- Begin Message ---
On Fri, 2009-10-16 at 08:34 -0700, bruce wrote:

> Hi.
> 
> I've got a situation where I have a couple of tables. The relationship
> between the tables is one of parent/child. I'm trying to figure out the best
> approach to being able to delete the associated children in the child tbls,
> of a given parentID in the parentTBL...
> 
> I've checked into various sites/articles on the 'net.. but i'm not sure how
> best to accomplish this...
> 
> I'm using php as the interface language to the test tbls..
> 
> Any pointers/articles/test code (code/schema) would be helpful...
> 
> Thanks
> 
> 
> 


Well if the tables truly have a relationship, then no PHP is necessary.

I assume that to connect the 'parent' row with the 'children' rows of
the secondary table you've used an identifying field. For example:

users table:
user_id
forename
surname

emails table:
email_id
user_id
email_address

So in the above example, a user on the users table could have several
entries in the emails table for each email address they have.
emails.user_id will match up users.user_id so you can run a query like

DELETE FROM emails WHERE user_id=id

Is this any help?


Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
How would you read this out loud if you were to read it to someone
over  the phone?

($item->getServiceId() ? $item->getServiceId() : $item->getId())));

Thanks!

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il

--- End Message ---

Reply via email to