php-general Digest 19 Mar 2010 07:06:30 -0000 Issue 6647

Topics (messages 302972 through 302994):

Re: Spreadsheet_Excel_Reader problem
        302972 by: Paul M Foster
        302974 by: Paul M Foster
        302977 by: Ashley Sheridan
        302980 by: Andrew Ballard
        302985 by: Paul M Foster

Re: PHP in HTML code
        302973 by: Ashley Sheridan
        302975 by: Jan G.B.
        302976 by: Ashley Sheridan
        302978 by: Adam Richardson
        302979 by: Jan G.B.
        302981 by: Ashley Sheridan
        302982 by: Jan G.B.
        302983 by: Ashley Sheridan
        302984 by: Adam Richardson

web sniffer
        302986 by: madunix
        302987 by: Ashley Sheridan
        302988 by: Adam Richardson
        302989 by: madunix
        302990 by: Ashley Sheridan
        302991 by: Adam Richardson
        302992 by: madunix

Re: confirm subscribe to php-gene...@lists.php.net
        302993 by: Blake Morgan

Example of good PHP namespace usage?
        302994 by: D. Dante Lorenso

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 ---
On Thu, Mar 18, 2010 at 09:16:30AM -0700, Mattias Thorslund wrote:

> Paul M Foster wrote:
>> I process a lot of CSV files, and what I typically see is that Excel
>> will enclose fields which might contain commas in quotes. This gets
>> messy. So I finally wrote a C utility which parses the file and yields
>> tab-delimited records without the quotes.
>>
>> Paul
>>
>
> And fgetcsv() didn't work for you?
>
> http://www.php.net/fgetcsv

I wrote my utility (and the infrastructure to process these files) long
before I was working with PHP. For what I do with the files, I must pipe
one operation's results to another process/command to get the final
result. This is impossible with web-based PHP. So I shell out from PHP
to do it. Like this:

// convert original file to tab-delimited
cat maillist.csv | cqf | filter.cq3or4 > jones.tab
// filter unwanted fields and reorder fields
mlt3.py nady jones.tab jones.rdb
// build basic DBF file
dbfsak -r mailers.rdb jones.dbf
// append rdb records to DBF file
dbfsak -a jones.rdb jones.dbf

Paul

-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---
On Thu, Mar 18, 2010 at 04:15:33PM +0000, Ashley Sheridan wrote:

> On Thu, 2010-03-18 at 12:12 -0400, Paul M Foster wrote:
> 
>     On Thu, Mar 18, 2010 at 08:57:00AM -0700, Tommy Pham wrote:
> 
>     <snip>
> 
>     >
>     > Personally, I find working with fixed widths is best.  The text file
>     > might be larger but I don't have worry about escaping any type of
>     > characters ;)
> 
>     I find this impossible, since I never know the largest width of all the
>     fields in a file. And a simple explode() call allows pulling all the
>     fields into an array, based on a common delimiter.
> 
>     Paul
> 
>     --
>     Paul M. Foster
> 
> 
> 
> Explode won't work in the case of a comma in a field value.

That's why I convert the files to tab-delimited first. explode() does
work in that case.

> 
> Also, newlines can exist within a field value, so a line in the file doesn't
> equate to a row of data

I've never seen this in the files I receive.

> 
> The best way is just to start parsing at the beginning of the file and break 
> it
> into fields one by one from there.
> 
> The bit I don't like about characters other than a comma being used in a 
> "comma
> separated values" file is that you can't automatically tell what character has
> been used as the delimiter. Hence being asked by spreadsheet programs what the
> delimiter is if a comma doesn't give up what it recognises as valid fields.

I've honestly never seen a "CSV" or "Comma-separated Values" which used
tabs for delimiters. At that point, it's really not a *comma* separated
value file.

My application for all this is accepting mailing lists from customers
which I have to convert into DBFs for a commercial mailing list program.
Because most of my customers can barely find the on/off switch on their
computers, I never know what I'm going to get. So before I string
together the filters to process the file, I have to actually look at and
analyze the file to find out what it is. Could be a fixed-field length
file, a CSV, a tab-delimited file, or anything in between. Once I've
selected the filters, the sequence they will be put together in, and the
fields from the file I want to capture, I hit the button. After it's all
done, I now have to look at the result to ensure that the requested
fields ended up where they were supposed to.

Paul

-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---
On Thu, 2010-03-18 at 12:57 -0400, Paul M Foster wrote:

> On Thu, Mar 18, 2010 at 04:15:33PM +0000, Ashley Sheridan wrote:
> 
> > On Thu, 2010-03-18 at 12:12 -0400, Paul M Foster wrote:
> > 
> >     On Thu, Mar 18, 2010 at 08:57:00AM -0700, Tommy Pham wrote:
> > 
> >     <snip>
> > 
> >     >
> >     > Personally, I find working with fixed widths is best.  The text file
> >     > might be larger but I don't have worry about escaping any type of
> >     > characters ;)
> > 
> >     I find this impossible, since I never know the largest width of all the
> >     fields in a file. And a simple explode() call allows pulling all the
> >     fields into an array, based on a common delimiter.
> > 
> >     Paul
> > 
> >     --
> >     Paul M. Foster
> > 
> > 
> > 
> > Explode won't work in the case of a comma in a field value.
> 
> That's why I convert the files to tab-delimited first. explode() does
> work in that case.
> 
> > 
> > Also, newlines can exist within a field value, so a line in the file doesn't
> > equate to a row of data
> 
> I've never seen this in the files I receive.
> 
> > 
> > The best way is just to start parsing at the beginning of the file and 
> > break it
> > into fields one by one from there.
> > 
> > The bit I don't like about characters other than a comma being used in a 
> > "comma
> > separated values" file is that you can't automatically tell what character 
> > has
> > been used as the delimiter. Hence being asked by spreadsheet programs what 
> > the
> > delimiter is if a comma doesn't give up what it recognises as valid fields.
> 
> I've honestly never seen a "CSV" or "Comma-separated Values" which used
> tabs for delimiters. At that point, it's really not a *comma* separated
> value file.
> 
> My application for all this is accepting mailing lists from customers
> which I have to convert into DBFs for a commercial mailing list program.
> Because most of my customers can barely find the on/off switch on their
> computers, I never know what I'm going to get. So before I string
> together the filters to process the file, I have to actually look at and
> analyze the file to find out what it is. Could be a fixed-field length
> file, a CSV, a tab-delimited file, or anything in between. Once I've
> selected the filters, the sequence they will be put together in, and the
> fields from the file I want to capture, I hit the button. After it's all
> done, I now have to look at the result to ensure that the requested
> fields ended up where they were supposed to.
> 
> Paul
> 
> -- 
> Paul M. Foster
> 


But surely whatever character is used as the delimiter could be part of
the fields value?

I hadn't even known that newlines would exist in the fields, until it
broke a script of mine!

And I believe that when MS Office saves a CSV out with a character other
than a comma as the delimiter, it still saves it as a .csv by default.

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



--- End Message ---
--- Begin Message ---
On Thu, Mar 18, 2010 at 1:00 PM, Ashley Sheridan
<a...@ashleysheridan.co.uk> wrote:
[snip]
> And I believe that when MS Office saves a CSV out with a character other
> than a comma as the delimiter, it still saves it as a .csv by default.

Nope. If you save as CSV, it is comma-separated with double-quotes as
the text qualifier. There is also an option to save in tab-delimited
format, but the default extension for that is .txt.

The only issue I have with Excel handling text files is with columns
like ZIP code that should be treated as text (they are string
sequences that happen to contain only numeric digits where leading
zeros are significant) but are interpreted as numbers.

Andrew

--- End Message ---
--- Begin Message ---
On Thu, Mar 18, 2010 at 05:00:24PM +0000, Ashley Sheridan wrote:

> On Thu, 2010-03-18 at 12:57 -0400, Paul M Foster wrote:
> 
>     On Thu, Mar 18, 2010 at 04:15:33PM +0000, Ashley Sheridan wrote:
> 
>     > On Thu, 2010-03-18 at 12:12 -0400, Paul M Foster wrote:
>     >
>     >     On Thu, Mar 18, 2010 at 08:57:00AM -0700, Tommy Pham wrote:
>     >

<snip>

>     > Explode won't work in the case of a comma in a field value.
> 
>     That's why I convert the files to tab-delimited first. explode() does
>     work in that case.
> 
>     >
>     > Also, newlines can exist within a field value, so a line in the
>     file doesn't
>     > equate to a row of data
> 
>     I've never seen this in the files I receive.
> 
>     >
>     > The best way is just to start parsing at the beginning of the file
>     and break it
>     > into fields one by one from there.
>     >
>     > The bit I don't like about characters other than a comma being used
>     in a "comma
>     > separated values" file is that you can't automatically tell what
>     character has
>     > been used as the delimiter. Hence being asked by spreadsheet programs
>     what the
>     > delimiter is if a comma doesn't give up what it recognises as valid
>     fields.
> 
>     I've honestly never seen a "CSV" or "Comma-separated
>     Values" which used
>     tabs for delimiters. At that point, it's really not a *comma* separated
>     value file.
> 
>     My application for all this is accepting mailing lists from customers
>     which I have to convert into DBFs for a commercial mailing list program.
>     Because most of my customers can barely find the on/off switch on their
>     computers, I never know what I'm going to get. So before I string
>     together the filters to process the file, I have to actually look at and
>     analyze the file to find out what it is. Could be a fixed-field length
>     file, a CSV, a tab-delimited file, or anything in between. Once I've
>     selected the filters, the sequence they will be put together in, and the
>     fields from the file I want to capture, I hit the button. After it's all
>     done, I now have to look at the result to ensure that the requested
>     fields ended up where they were supposed to.
> 
>     Paul
> 
>     --
>     Paul M. Foster
> 
> 
> 
> But surely whatever character is used as the delimiter could be part of the
> fields value?

Well, remember I shove these into tab-delimited files. It does
occasionally happen that someone will slip a tab into a field. When that
happens, I can tell when the final result is off. Then I do a hex dump
of the file (in PHP) to determine if it actually is a tab. If so, I have
a filter I prepend to the line of filters which removes tabs from the
original CSV file. Then proceed as before.

Occasionally someone will send me a file in a "label" format which
contains \x0C characters or somesuch at page boundaries. I actually have
to look at the file and find out what they've inserted. I have filters
for most anything I find like that.

Paul

-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---
On Thu, 2010-03-18 at 17:32 +0100, Jan G.B. wrote:

> 2010/3/18 tedd <tedd.sperl...@gmail.com>:
> > Calling it "ranting" or "religious" unjustly demeans the discussion and is
> > inflammatory.
> > In all of this, I've simply said it's your choice.
> 
> What I said was:
> *persons ranting about short open tags* *are just like some religious people
> *
> 
> I did not address you.
> 
> On the other hand you're telling people here that their approach is "worse"
> and yours is great. IMHO this isn't a discussion but bashing without any
> reasoning.
> You simply say that XML is confused by a short open tag, but actually PHP is
> not embedded in XML.
> 
> I quote you:
> > that's your choice -- but your decision is also a demonstration to your
> client/employer/peers as to your desire to produce the "best" possible code.
> > I look at code containing "<?=" the same way as I see html containing
> tables and embedded styling for presentation -- "This must be old code OR
> the programmer still doesn't get it".
> 
> You make it very clear that you believe in your superior coding style.


Technically, PHP isn't embedded in any language; it's the other way
around.

XML and PHP are used together more often than you might realise.
Consider Ajax and RSS, which are becoming more and more popular. Also,
there are sites out there that are almost entirely XML-based; just have
a look at the World of Warcraft (yes I play it!) website.

For me, I originally learnt PHP using the <?php tags. I only found out
about short tags when I first ran into the problem with them on shared
hosting that had them turned off. To me, it didn't make much sense in
using something that wasn't portable. For the same reason, I try to
avoid using obscure PHP modules when I know a system will end up on a
closed hosting platform like this.

I hear the arguments that short tags make code easier to read and write,
but from experience, a good syntax highlighter does the trick for the
former, and I don't feel that typing a few extra characters is really
delaying me by much.

I have seen someone argue about screen readers having problems by
reading out the <?php each time, and I don't know how that would be
dealt with in reality. Are there PHP-aware screen readers about, or at
least screen readers that might be told to ignore particular patterns of
content?

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



--- End Message ---
--- Begin Message ---
2010/3/18 Ashley Sheridan <a...@ashleysheridan.co.uk>

> Technically, PHP isn't embedded in any language; it's the other way around.
>
> XML and PHP are used together more often than you might realise. Consider
> Ajax and RSS, which are becoming more and more popular. Also, there are
> sites out there that are almost entirely XML-based; just have a look at the
> World of Warcraft (yes I play it!) website.
>
> Sure - XML is often used and served.
But in general, a web server only parses PHP-Files (ie. .+\.php\d?) unless
you configure your server to parse any file or .xml files. So the XML <? is
not a problem at all for the interpreter.



> For me, I originally learnt PHP using the <?php tags. I only found out
> about short tags when I first ran into the problem with them on shared
> hosting that had them turned off. To me, it didn't make much sense in using
> something that wasn't portable. For the same reason, I try to avoid using
> obscure PHP modules when I know a system will end up on a closed hosting
> platform like this.
>
>
My opinion to this is that I seperate markup from code. I use a template
system in my .tpl files and these will never get parsed. Inline PHP is not
my choice.
But when I'm about to update a project that is written with inline php, I
appreciate the short tags for their ease of use. I also enjoy typing less.
:-)

Regards

--- End Message ---
--- Begin Message ---
On Thu, 2010-03-18 at 17:57 +0100, Jan G.B. wrote:

> Sure - XML is often used and served. But in general, a web server only
> parses PHP-Files (ie. .+\.php\d?) unless you configure your server to
> parse any file or .xml files. So the XML <? is not a problem at all
> for the interpreter.


I wasn't meaning that xml files would be parsed as PHP, but that PHP
would be used to output XML. I'd rather have short tags turned off than
remember each time that I have to keep breaking up the < and ?php before
I output it in-case the parser gets confused.

Templating is great, but it's not for all projects.

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



--- End Message ---
--- Begin Message ---
On Thu, Mar 18, 2010 at 11:28 AM, tedd <tedd.sperl...@gmail.com> wrote:

> At 9:34 AM +0000 3/18/10, Pete Ford wrote:
>
>>
>> I do tend to use <?php for blocks of code - so I guess I'm in the middle
>> camp here.
>>
>
>
> Whoa, that's even worse -- make a choice and stick with it -- IMO.
>
> I'm all for consistency and have often found myself redoing dozens of
> scripts because I changed something -- not because the change worked and the
> other didn't, but rather to maintain consistency throughout the project.
>
> Granted, different reasons promote different programming styles. While what
> I do is to solve the problem at hand for the client, it also has to pass
> through my vision of code elegance. I program for myself first and solve the
> client's problems second. I also realize that I have the privilege of doing
> so because my needs are few. I probably wouldn't do well in a production
> oriented environment.
>
> 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
>
>

What Pete described is consistent.

For blocks that merely echo out a variable in templates or views, he uses a
<?=, and in code that's actually doing some manipulation, he uses <?php.

This consistency does make it very easy to discern the difference, saves on
typing, and similar approaches are used in other frameworks (e.g., ASP.Net),
too.

Adam

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com

--- End Message ---
--- Begin Message ---
2010/3/18 Ashley Sheridan <a...@ashleysheridan.co.uk>

>  I'd rather have short tags turned off than remember each time that I have
> to keep breaking up the < and ?php before I output it in-case the parser
> gets confused.
>

You don't need to break anything up. It's perfectly valid and without
problems:

<?php echo '<?xml version.... ?>'; ?>

--- End Message ---
--- Begin Message ---
On Thu, 2010-03-18 at 18:09 +0100, Jan G.B. wrote:

> 2010/3/18 Ashley Sheridan <a...@ashleysheridan.co.uk>
> 
> >  I'd rather have short tags turned off than remember each time that I have
> > to keep breaking up the < and ?php before I output it in-case the parser
> > gets confused.
> >
> 
> You don't need to break anything up. It's perfectly valid and without
> problems:
> 
> <?php echo '<?xml version.... ?>'; ?>


What about this:

<?xml version="1.0">
<?php

That would break with short tags turned on. I often use this sort of
code in my Ajax server stuff. I don't want to have to use PHP to echo
out what would work on a normal setup.

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



--- End Message ---
--- Begin Message ---
2010/3/18 Ashley Sheridan <a...@ashleysheridan.co.uk>

>  On Thu, 2010-03-18 at 18:09 +0100, Jan G.B. wrote:
>
> 2010/3/18 Ashley Sheridan <a...@ashleysheridan.co.uk>
>
> >  I'd rather have short tags turned off than remember each time that I have
> > to keep breaking up the < and ?php before I output it in-case the parser
> > gets confused.
> >
>
> You don't need to break anything up. It's perfectly valid and without
> problems:
>
> <?php echo '<?xml version.... ?>'; ?>
>
>
> What about this:
>
> <?xml version="1.0">
> <?php
>
>
It's confusing! =)


> That would break with short tags turned on. I often use this sort of code
> in my Ajax server stuff. I don't want to have to use PHP to echo out what
> would work on a normal setup.
>

I can understand it. But I think it's nonsense to output one line of "text"
(prolog) and then start with <?php - while arguing that the first line of
PHP should not be an echo. Where's the point?



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

--- End Message ---
--- Begin Message ---
On Thu, 2010-03-18 at 18:37 +0100, Jan G.B. wrote:

> 
> 
> 2010/3/18 Ashley Sheridan <a...@ashleysheridan.co.uk>
> 
>         
>         On Thu, 2010-03-18 at 18:09 +0100, Jan G.B. wrote: 
>         
>         > 2010/3/18 Ashley Sheridan <a...@ashleysheridan.co.uk>
>         > 
>         > >  I'd rather have short tags turned off than remember each time 
> that I have
>         > > to keep breaking up the < and ?php before I output it in-case the 
> parser
>         > > gets confused.
>         > >
>         > 
>         > You don't need to break anything up. It's perfectly valid and 
> without
>         > problems:
>         > 
>         > <?php echo '<?xml version.... ?>'; ?>
>         
>         
>         
>         
>         What about this:
>         
>         <?xml version="1.0">
>         <?php
>         
>         
> 
> 
> 
> It's confusing! =)
> 
>  
>         That would break with short tags turned on. I often use this
>         sort of code in my Ajax server stuff. I don't want to have to
>         use PHP to echo out what would work on a normal setup.
> 
> 
> I can understand it. But I think it's nonsense to output one line of
> "text" (prolog) and then start with <?php - while arguing that the
> first line of PHP should not be an echo. Where's the point?
> 
> 
> 
> 
>         
>         
>         Thanks,
>         Ash
>         http://www.ashleysheridan.co.uk
>         
>         
>         
> 
> 


That was just a really small example. Imagine the <?xml line followed by
other lines of actual XML content that might remain static:

<?xml version="1.0">
<content>
    <other_stuff/>
    <even_more_stuff/>
    <?php
    // code that changes here
    ?>
</content>

I could use heredoc or nowdoc, but why that's just ugly, and the
resulting XML inside the heredoc/nowdoc isn't recognised as XML by any
editor I know of. All of that to avoid writing a few extra characters to
"save myself some work"...

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



--- End Message ---
--- Begin Message ---
On Thu, Mar 18, 2010 at 1:37 PM, Ashley Sheridan
<a...@ashleysheridan.co.uk>wrote:

> On Thu, 2010-03-18 at 18:37 +0100, Jan G.B. wrote:
>
> >
> >
> > 2010/3/18 Ashley Sheridan <a...@ashleysheridan.co.uk>
> >
> >
> >         On Thu, 2010-03-18 at 18:09 +0100, Jan G.B. wrote:
> >
> >         > 2010/3/18 Ashley Sheridan <a...@ashleysheridan.co.uk>
> >         >
> >         > >  I'd rather have short tags turned off than remember each
> time that I have
> >         > > to keep breaking up the < and ?php before I output it in-case
> the parser
> >         > > gets confused.
> >         > >
> >         >
> >         > You don't need to break anything up. It's perfectly valid and
> without
> >         > problems:
> >         >
> >         > <?php echo '<?xml version.... ?>'; ?>
> >
> >
> >
> >
> >         What about this:
> >
> >         <?xml version="1.0">
> >         <?php
> >
> >
> >
> >
> >
> > It's confusing! =)
> >
> >
> >         That would break with short tags turned on. I often use this
> >         sort of code in my Ajax server stuff. I don't want to have to
> >         use PHP to echo out what would work on a normal setup.
> >
> >
> > I can understand it. But I think it's nonsense to output one line of
> > "text" (prolog) and then start with <?php - while arguing that the
> > first line of PHP should not be an echo. Where's the point?
> >
> >
> >
> >
> >
> >
> >         Thanks,
> >         Ash
> >         http://www.ashleysheridan.co.uk
> >
> >
> >
> >
> >
>
>
> That was just a really small example. Imagine the <?xml line followed by
> other lines of actual XML content that might remain static:
>
> <?xml version="1.0">
> <content>
>    <other_stuff/>
>    <even_more_stuff/>
>    <?php
>    // code that changes here
>    ?>
> </content>
>
> I could use heredoc or nowdoc, but why that's just ugly, and the
> resulting XML inside the heredoc/nowdoc isn't recognised as XML by any
> editor I know of. All of that to avoid writing a few extra characters to
> "save myself some work"...
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>

   - 310 characters.
   - Differentiation between code that's merely echoed and code that
   performs some operation.
   - XML is recognized by editors.
   - Easier for me to visually scan.

<?=  '<?xml version="1.0">' ?>
<content>
   <?php foreach ($rows as $row)  { ?>
   <row>
      <title><?= $row['title'] ?></title>
      <type><?= $row['type'] ?></type>
      <desc><?= $row['desc'] ?></desc>
      <date><?= $row['date'] ?></date>
      <other><?= $row['other'] ?></other>
   </row>
   <? } ?>
</content>




   - 340 characters.
   - All code blocks consistent.
   - XML recognized by editors.


<?xml version="1.0">
<content>
   <?php foreach ($rows as $row)  { ?>
   <row>
      <title><?php echo $row['title']; ?></title>
      <type><?php echo $row['type']; ?></type>
      <desc><?php echo $row['desc']; ?></desc>
      <date><?php echo $row['date']; ?></date>
      <other><?php echo $row['other']; ?></other>
   </row>
   <? } ?>
</content>

Given the choice, I'd rather work with the first option, but I have no
problem with those who prefer the second option.

Adam

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com

--- End Message ---
--- Begin Message ---
I've been trying to read the contents from a particular URL into a
string in PHP, and can't get it to work.  any help.

Thanks

-- 
If there is a way, I will find one...***
If there is none, I will make one..."***
**************** madunix  ******************

--- End Message ---
--- Begin Message ---
On Fri, 2010-03-19 at 00:03 +0200, madunix wrote:

> I've been trying to read the contents from a particular URL into a
> string in PHP, and can't get it to work.  any help.
> 
> Thanks
> 
> -- 
> If there is a way, I will find one...***
> If there is none, I will make one..."***
> **************** madunix  ******************
> 


How have you been trying to do it so far?

There are a couple of ways. file_get_contents() and fopen() will work on
URL's if the right ports are open.

Most usually though cURL is used for this sort of thing.

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



--- End Message ---
--- Begin Message ---
On Thu, Mar 18, 2010 at 6:03 PM, madunix <madu...@gmail.com> wrote:

> I've been trying to read the contents from a particular URL into a
> string in PHP, and can't get it to work.  any help.
>
> Thanks
>
> --
> If there is a way, I will find one...***
> If there is none, I will make one..."***
> **************** madunix  ******************
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
<?php
    $markup = file_get_contents('http://domain.com');
?>

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com

--- End Message ---
--- Begin Message ---
trying http://us3.php.net/manual/en/function.fsockopen.php
do you a piece of code that  read parts  pages.

On Fri, Mar 19, 2010 at 12:00 AM, Ashley Sheridan
<a...@ashleysheridan.co.uk>wrote:

>  On Fri, 2010-03-19 at 00:03 +0200, madunix wrote:
>
> I've been trying to read the contents from a particular URL into a
> string in PHP, and can't get it to work.  any help.
>
> Thanks
>
> --
> If there is a way, I will find one...***
> If there is none, I will make one..."***
> **************** madunix  ******************
>
>
>
> How have you been trying to do it so far?
>
> There are a couple of ways. file_get_contents() and fopen() will work on
> URL's if the right ports are open.
>
> Most usually though cURL is used for this sort of thing.
>
>   Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>


-- 
If there is a way, I will find one...***
If there is none, I will make one..."***
**************** madunix  ******************

--- End Message ---
--- Begin Message ---
On Fri, 2010-03-19 at 00:11 +0200, madunix wrote:
> trying http://us3.php.net/manual/en/function.fsockopen.php
> do you a piece of code that  read parts  pages.
> 
> 
> On Fri, Mar 19, 2010 at 12:00 AM, Ashley Sheridan
> <a...@ashleysheridan.co.uk> wrote:
> 
>         
>         On Fri, 2010-03-19 at 00:03 +0200, madunix wrote: 
>         
>         > I've been trying to read the contents from a particular URL into a
>         > string in PHP, and can't get it to work.  any help.
>         > 
>         > Thanks
>         > 
>         > -- 
>         > If there is a way, I will find one...***
>         > If there is none, I will make one..."***
>         > **************** madunix  ******************
>         > 
>         
>         
>         
>         
>         How have you been trying to do it so far?
>         
>         There are a couple of ways. file_get_contents() and fopen()
>         will work on URL's if the right ports are open.
>         
>         Most usually though cURL is used for this sort of thing.
>         
>         Thanks,
>         Ash
>         http://www.ashleysheridan.co.uk
>         
>         
>         
> 
> 
> 
> 
> -- 
> If there is a way, I will find one...***
> If there is none, I will make one..."***
> **************** madunix  ******************
> 
> 

I think you're over-complicating things by using fsockopen(). Try one of
the functions I mentioned in my last email

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



--- End Message ---
--- Begin Message ---
On Thu, Mar 18, 2010 at 6:08 PM, Ashley Sheridan
<a...@ashleysheridan.co.uk>wrote:

> On Fri, 2010-03-19 at 00:11 +0200, madunix wrote:
> > trying http://us3.php.net/manual/en/function.fsockopen.php
> > do you a piece of code that  read parts  pages.
> >
> >
> > On Fri, Mar 19, 2010 at 12:00 AM, Ashley Sheridan
> > <a...@ashleysheridan.co.uk> wrote:
> >
> >
> >         On Fri, 2010-03-19 at 00:03 +0200, madunix wrote:
> >
> >         > I've been trying to read the contents from a particular URL
> into a
> >         > string in PHP, and can't get it to work.  any help.
> >         >
> >         > Thanks
> >         >
> >         > --
> >         > If there is a way, I will find one...***
> >         > If there is none, I will make one..."***
> >         > **************** madunix  ******************
> >         >
> >
> >
> >
> >
> >         How have you been trying to do it so far?
> >
> >         There are a couple of ways. file_get_contents() and fopen()
> >         will work on URL's if the right ports are open.
> >
> >         Most usually though cURL is used for this sort of thing.
> >
> >         Thanks,
> >         Ash
> >         http://www.ashleysheridan.co.uk
> >
> >
> >
> >
> >
> >
> >
> > --
> > If there is a way, I will find one...***
> > If there is none, I will make one..."***
> > **************** madunix  ******************
> >
> >
>
> I think you're over-complicating things by using fsockopen(). Try one of
> the functions I mentioned in my last email
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
I agree with Ashley, use one of the other options and then parse the
response to get the part of the page you'd like to work with.

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com

--- End Message ---
--- Begin Message ---
okay ..it works now i use
<?php
$data=file_get_contents("http://www.my.com";);
echo $data;
?>

On Fri, Mar 19, 2010 at 12:32 AM, Adam Richardson <simples...@gmail.com> wrote:
> On Thu, Mar 18, 2010 at 6:08 PM, Ashley Sheridan <a...@ashleysheridan.co.uk>
> wrote:
>>
>> On Fri, 2010-03-19 at 00:11 +0200, madunix wrote:
>> > trying http://us3.php.net/manual/en/function.fsockopen.php
>> > do you a piece of code that  read parts  pages.
>> >
>> >
>> > On Fri, Mar 19, 2010 at 12:00 AM, Ashley Sheridan
>> > <a...@ashleysheridan.co.uk> wrote:
>> >
>> >
>> >         On Fri, 2010-03-19 at 00:03 +0200, madunix wrote:
>> >
>> >         > I've been trying to read the contents from a particular URL
>> > into a
>> >         > string in PHP, and can't get it to work.  any help.
>> >         >
>> >         > Thanks
>> >         >
>> >         > --
>> >         > If there is a way, I will find one...***
>> >         > If there is none, I will make one..."***
>> >         > **************** madunix  ******************
>> >         >
>> >
>> >
>> >
>> >
>> >         How have you been trying to do it so far?
>> >
>> >         There are a couple of ways. file_get_contents() and fopen()
>> >         will work on URL's if the right ports are open.
>> >
>> >         Most usually though cURL is used for this sort of thing.
>> >
>> >         Thanks,
>> >         Ash
>> >         http://www.ashleysheridan.co.uk
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > --
>> > If there is a way, I will find one...***
>> > If there is none, I will make one..."***
>> > **************** madunix  ******************
>> >
>> >
>>
>> I think you're over-complicating things by using fsockopen(). Try one of
>> the functions I mentioned in my last email
>>
>> Thanks,
>> Ash
>> http://www.ashleysheridan.co.uk
>>
>>
>
> I agree with Ashley, use one of the other options and then parse the
> response to get the part of the page you'd like to work with.
>
> --
> Nephtali:  PHP web framework that functions beautifully
> http://nephtaliproject.com
>



-- 
If there is a way, I will find one...***
If there is none, I will make one..."***
**************** madunix  ******************

--- End Message ---
--- Begin Message ---
On 3/18/2010 9:36 PM, php-general-h...@lists.php.net wrote:
Hi! This is the ezmlm program. I'm managing the
php-gene...@lists.php.net mailing list.

I'm working for my owner, who can be reached
at php-general-ow...@lists.php.net.

To confirm that you would like

    bmorga...@gmail.com

added to the php-general mailing list, please send
an empty reply to this address:

    
php-general-sc.1268962598.gpkmhgepijekphmnnice-bmorganva=gmail....@lists.php.net

Usually, this happens when you just hit the "reply" button.
If this does not work, simply copy the address and paste it into
the "To:" field of a new message.

or click here:
        
mailto:php-general-sc.1268962598.gpkmhgepijekphmnnice-bmorganva=gmail....@lists.php.net

This confirmation serves two purposes. First, it verifies that I am able
to get mail through to you. Second, it protects you in case someone
forges a subscription request in your name.

Some mail programs are broken and cannot handle long addresses. If you
cannot reply to this request, instead send a message to
<php-general-requ...@lists.php.net>  and put the
entire address listed above into the "Subject:" line.


--- Administrative commands for the php-general list ---

I can handle administrative requests automatically. Please
do not send them to the list address! Instead, send
your message to the correct command address:

For help and a description of available commands, send a message to:
    <php-general-h...@lists.php.net>

To subscribe to the list, send a message to:
    <php-general-subscr...@lists.php.net>

To remove your address from the list, just send a message to
the address in the ``List-Unsubscribe'' header of any list
message. If you haven't changed addresses since subscribing,
you can also send a message to:
    <php-general-unsubscr...@lists.php.net>

or for the digest to:
    <php-general-digest-unsubscr...@lists.php.net>

For addition or removal of addresses, I'll send a confirmation
message to that address. When you receive it, simply reply to it
to complete the transaction.

If you need to get in touch with the human owner of this list,
please send a message to:

     <php-general-ow...@lists.php.net>

Please include a FORWARDED list message with ALL HEADERS intact
to make it easier to help you.

--- Enclosed is a copy of the request I received.

Return-Path:<nore...@php.net>
Received: (qmail 37443 invoked from network); 19 Mar 2010 01:36:38 -0000
Received: from unknown (HELO lists.php.net) (127.0.0.1)
   by localhost with SMTP; 19 Mar 2010 01:36:38 -0000
Return-Path:<nore...@php.net>
Authentication-Results: pb1.pair.com smtp.mail=nore...@php.net; spf=pass; 
sender-id=pass
Authentication-Results: pb1.pair.com header.from=bmorga...@gmail.com; 
sender-id=unknown
Received-SPF: pass (pb1.pair.com: domain php.net designates 140.211.166.39 as 
permitted sender)
X-PHP-List-Original-Sender: nore...@php.net
X-Host-Fingerprint: 140.211.166.39 osu1.php.net Linux 2.4/2.6
Received: from [140.211.166.39] ([140.211.166.39:35224] helo=osu1.php.net)
        by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP
        id 57/A0-31664-525D2AB4 
for<php-general-subscribe-bmorganva=gmail....@lists.php.net>; Thu, 18 Mar 2010 
20:36:38 -0500
Authentication-Results: osu1.php.net header.from=bmorga...@gmail.com; 
sender-id=neutral
Authentication-Results: osu1.php.net smtp.mail=nore...@php.net; spf=neutral; 
sender-id=neutral
Received: from [127.0.0.1] ([127.0.0.1:35215] helo=osu1.php.net)
        by osu1.php.net (envelope-from<nore...@php.net>)
        (ecelerity 2.2.2.32 r(25190M)) with ESMTP
        id F4/25-12636-549D2AB4; Thu, 18 Mar 2010 17:54:18 -0800
Received: (from apa...@localhost)
        by osu1.php.net (8.12.11/8.12.11/Submit) id o2J1sBWu030283;
        Thu, 18 Mar 2010 17:54:11 -0800
Date: Thu, 18 Mar 2010 17:54:11 -0800
Message-Id:<201003190154.o2j1sbwu030...@osu1.php.net>
To: php-general-subscribe-bmorganva=gmail....@lists.php.net
Subject: PHP Mailing List Website Subscription
From: bmorga...@gmail.com


This was a request generated from the form at 
http://www.php.net/mailing-lists.php by 71.246.203.235.


--- End Message ---
--- Begin Message ---
All,

I want to start using PHP namespaces for my projects. Currently, I name my classes similar to how Zend Framework names theirs and I end up with classes like:

  LS_Util_String

I'm thinking that if I converted this to namespaces, the classes would be named like:

  LS\Util\String

I'd like to look at an example of an open source project that has already adopted namespaces as "the way to do it" and would be a good best practices case for how I should go about setting up my library namespaces.

I have been playing with concepts of using a Java-like naming convention for classes and have created my own namespace like:

    com\larkspark\util\String

And here I was thinking that packages would be lowercase and classes would be camelcase with initial caps.

I'm getting ready to build a new project and wanted to do it in the future-forward style while removing legacy classes and refactoring everything to use namespaces.

Any examples out there? Everything I find from searching Google is novice intro to PHP namespaces blogs, but nothing concrete. Also since namespaces are relatively new, I see a lot of misleading guides where they are using "::" instead of "\" to separate class name parts. What does this list recommend?

Dante

--- End Message ---

Reply via email to