Re: [PHP] best way to determine mime type of file these days?
Robert P. J. Day wrote: i realize it sounds trivial but the online info is annoyingly recursive. there's mime_content_type(), but it's officially deprecated. On the manual page there is a reference to the Fileinfo PECL extension: http://php/manual/en/ref.fileinfo.php -- Per Jessen, Zürich (9.1°C) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP in HTML code
On 17/03/10 18:59, Tommy Pham wrote: On Wed, Mar 17, 2010 at 11:01 AM, Rene Veermanrene7...@gmail.com wrote: hmm.. seems easier to me to push a filetree of .php's with?= through the str_replace(), than it is to get all the?= writers to comply with your wishes, which may not apply to their situation ;-) On Wed, Mar 17, 2010 at 5:14 PM, teddtedd.sperl...@gmail.com wrote: At 8:55 PM -0400 3/16/10, Adam Richardson wrote: That said, I'm not taking exception with those who don't use the short tag, only with those who say I shouldn't. Exception or not, it's still your choice and using short tags can cause problems. My view, why create problems when there is a solution? Forcing the issue is a bit like I'm going to do it my way regardless! I've traveled that path too many times in my life. Sometimes it's easier to take the path most traveled. Cheers, ted -- --- 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php http://www.php.net/manual/en/language.basic-syntax.phpmode.php There are four different pairs of opening and closing tags which can be used in PHP. Two of those,?php ? andscript language=php /script, are always available. The other two are short tags and ASP style tags, and can be turned on and off from the php.ini configuration file. As such, while some people find short tags and ASP style tags convenient, they are less portable, and generally not recommended. But the implication there is that they are *only* non-portable *because* they can be switched off - there's no other strong reason. Before anyone jumps in with XML / XHTML arguments again, those issues are fairly rare and very easily worked around. My projects tend to use XHTML doctype because it makes IE7/8 behave more predictably without a ?xml ? block, and I always use short tags for ?= because the alternative is so ugly! In the rare cases where I generate XML from a PHP script, there are workarounds for the ? problem. I do tend to use ?php for blocks of code - so I guess I'm in the middle camp here. I also write code to be hosted on dedicated systems that I have full control over, so php.ini settings are always in my control (so far...) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Spreadsheet_Excel_Reader problem
On Thu, 2010-03-18 at 19:21 +0800, I am on the top of the world! Borlange University wrote: sounds good, i havnt checked out it with cvs format. thanks On Tue, Mar 16, 2010 at 8:15 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Tue, 2010-03-16 at 20:16 +0800, I am on the top of the world! Borlange University wrote: i have a problem of reading values from excel file via spreadsheet_excel_reader which is a php class used to manipulate excel files. $data = new Spreadsheet_Excel_Reader(); $data-setOutputEncoding('CP936'); $data-read(d:\\tmp.xls); $rows=$data-sheets[0]['numRows']; $cell = $data-sheets[0]['cells'][1][1]; if i type many rows,say 1000, in the tmp.xls, it can read, $rows shows 1000, however, 1000 rows of data are copied from another excel file and these cells may have different background or other changes that differ from normal cells, it fails to read.the variable $rows shows nothingwhat i can do now is to split these data into small groups, small enough to be read, it really takes plenty of time. i dont know why, has somebody met this problem ever? If it's just the data you need, try using a csv file instead. The Excel format is closed, and as such, the PHP classes won't have full support for all of it's features. It seems like formatting is causing the data to be written to the spreadsheet differently maybe. Thanks, Ash http://www.ashleysheridan.co.uk The .csv format is just a plain text format, so you won't get formatting or formulas in your 'sheets' (csv is also a sheetless format) but it's been used for years by many systems for data. A lot of database systems will let you import csv files as well, which is quite convenient, although you will have to make sure the csv uses commas to delimit the data. Microsoft managed to basterdise this format a bit as well, and lets you use tabs, spaces and all sorts of other characters to delimit data fields. Someone obviously didn't mention to them that the file type is 'comma separated values'! Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Spreadsheet_Excel_Reader problem
On Thu, 2010-03-18 at 12:56 +0100, Jochen Schultz wrote: Microsoft managed to basterdise this format a bit as well, and lets you use tabs, spaces and all sorts of other characters to delimit data fields. Someone obviously didn't mention to them that the file type is 'comma separated values'! Or maybe it is because someone told them, that there is data out there, that might contain commas? regards Jochen The csv format allows for quote marks which can serve to escape commas: data, with commas And for escaping quote marks, you just use triple quote marks: some text with quotes Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Spreadsheet_Excel_Reader problem
Microsoft managed to basterdise this format a bit as well, and lets you use tabs, spaces and all sorts of other characters to delimit data fields. Someone obviously didn't mention to them that the file type is 'comma separated values'! Or maybe it is because someone told them, that there is data out there, that might contain commas? regards Jochen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Spreadsheet_Excel_Reader problem
On Thu, Mar 18, 2010 at 11:35:33AM +, Ashley Sheridan wrote: snip The .csv format is just a plain text format, so you won't get formatting or formulas in your 'sheets' (csv is also a sheetless format) but it's been used for years by many systems for data. A lot of database systems will let you import csv files as well, which is quite convenient, although you will have to make sure the csv uses commas to delimit the data. Microsoft managed to basterdise this format a bit as well, and lets you use tabs, spaces and all sorts of other characters to delimit data fields. Someone obviously didn't mention to them that the file type is 'comma separated values'! 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 -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I need a fresh look at storing variables in MySQL
At 5:18 PM -0700 3/17/10, Tommy Pham wrote: -snip- Below is how I'd do the db structure: tbl_survey_questions: questionId = int / uid your call languageId = int / uid / char your call if you intend to I18n it ;) question = varchar length is your requirement PK questionId + languageId tbl_participants: userId = int / uid userName = varchar PK userId tbl_answers: userId = int / uid questionId = int / uid languageId = int / uid answer = varchar / mediumtext / or another type of text field PK userId + questionId + languageId The reason why I'd structure it like this is: Let's say you have question 1 with 5 (a-e) multiple choices, you aggregrate your query (GROUP BY) to db for question 1 and see how many responses are for a to e (each). If your survey is I18n and your DB reflects it, you can even analyze how/why certain cultural background would choose each of those answer. (don't flame me... I know the environment comes in to growing up too :p and that's way beyond the scope of this list ) Tommy: The way I handled this was that all responder aspects, such as cultural background, were all recorded before the responder started the survey. This was part an authorization process and the responders had to earn their way into the survey by providing personal data. If they did not, then they weren't allowed to enter the survey. Likewise, they had to turn javascript ON or they were not permitted to continue. Please understand that in this survey, the purpose was that the client wasn't hoping for responders to fill out the survey (even though they would like them to), but rather providing a method for the membership to show their preferences in a union contract for their collective interest. As such, responders had a vested interest in participating. The survey would take between 20 to 60 minutes to complete and thus required a significant time investment. Considering that each answer (or series) could be compared to any number of others, I thought it best to make each question/answer created an individual record -- the table was very simple: survey_id question_id key1 key2 answer 1) The union wants several surveys like this, so I provided a survey_id. 2) The question_id was simply an identifier for the question -- a remote key to a question table. 3) Key1 and Key2 were simply values that were intended to tie the question/answer pairs together into a single event (i.e., a vote). 4) Answer -- what we are after. This format lends itself well to analyses using MySQL. 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] Spreadsheet_Excel_Reader problem
AFAIK, there is no real standard out there for CSV file definition and since Microsoft and many others (me too btw) use other chars for field separation in so called CSV files, i think it is a good way to deal with it and let it be how it is (actually i have to look into every CSV file that is going to be exchanged and that has some advantages as well). Btw. who told you to use tripple quotes? http://www.rfc-editor.org/rfc/rfc4180.txt 7. If double-quotes are used to enclose fields, then a double-quote appearing inside a field must be escaped by preceding it with another double quote. For example: aaa,bbb,ccc regards Jochen Ashley Sheridan schrieb: On Thu, 2010-03-18 at 12:56 +0100, Jochen Schultz wrote: Microsoft managed to basterdise this format a bit as well, and lets you use tabs, spaces and all sorts of other characters to delimit data fields. Someone obviously didn't mention to them that the file type is 'comma separated values'! Or maybe it is because someone told them, that there is data out there, that might contain commas? regards Jochen The csv format allows for quote marks which can serve to escape commas: data, with commas And for escaping quote marks, you just use triple quote marks: some text with quotes Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP in HTML code
2010/3/18 Pete Ford p...@justcroft.com: On 17/03/10 18:59, Tommy Pham wrote: On Wed, Mar 17, 2010 at 11:01 AM, Rene Veermanrene7...@gmail.com wrote: hmm.. seems easier to me to push a filetree of .php's with?= through the str_replace(), than it is to get all the?= writers to comply with your wishes, which may not apply to their situation ;-) On Wed, Mar 17, 2010 at 5:14 PM, teddtedd.sperl...@gmail.com wrote: At 8:55 PM -0400 3/16/10, Adam Richardson wrote: That said, I'm not taking exception with those who don't use the short tag, only with those who say I shouldn't. Exception or not, it's still your choice and using short tags can cause problems. My view, why create problems when there is a solution? Forcing the issue is a bit like I'm going to do it my way regardless! I've traveled that path too many times in my life. Sometimes it's easier to take the path most traveled. Cheers, ted -- --- 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php http://www.php.net/manual/en/language.basic-syntax.phpmode.php There are four different pairs of opening and closing tags which can be used in PHP. Two of those,?php ? andscript language=php /script, are always available. The other two are short tags and ASP style tags, and can be turned on and off from the php.ini configuration file. As such, while some people find short tags and ASP style tags convenient, they are less portable, and generally not recommended. But the implication there is that they are *only* non-portable *because* they can be switched off - there's no other strong reason. Before anyone jumps in with XML / XHTML arguments again, those issues are fairly rare and very easily worked around. My projects tend to use XHTML doctype because it makes IE7/8 behave more predictably without a ?xml ? block, and I always use short tags for ?= because the alternative is so ugly! In the rare cases where I generate XML from a PHP script, there are workarounds for the ? problem. I do tend to use ?php for blocks of code - so I guess I'm in the middle camp here. I also write code to be hosted on dedicated systems that I have full control over, so php.ini settings are always in my control (so far...) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I agree. And I believe the persons ranting about short open tags are just like some religious people. It's almost like a war between Linux/Windows/Mac, IE/FF or ASP/PHP. Also, people love to recommend things that others recommended before. It mustn't make a big sense. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP in HTML code
At 9:34 AM + 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
Re: [PHP] Re: PHP in HTML code
At 4:11 PM +0100 3/18/10, Jan G.B. wrote: I agree. And I believe the persons ranting about short open tags are just like some religious people. It's almost like a war between Linux/Windows/Mac, IE/FF or ASP/PHP. Also, people love to recommend things that others recommended before. It mustn't make a big sense. Calling it ranting or religious unjustly demeans the discussion and is inflammatory. In all of this, I've simply said it's your choice. While I believe and have stated my reasons, which are more than faith, you are free to do whatever you want. I don't consider any of this discussion (on either side of the argument) as religious' or ranting -- it's simply a discussion. 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
[PHP] protecting pages with a login system
Hi, I am wanting to protect some pages by requiring a user to log in to access them. I'd prefer this be as simple as possible, and without requiring a database. So for example when a user goes to www.domain.com/example.php they'll get a page prompting for their log in credentials, and only after providing them will the page display. I'd prefer to avoid basic authentication dialog boxes if possible. Suggestions appreciated. Thanks. Dave. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Spreadsheet_Excel_Reader problem
At 11:35 AM + 3/18/10, Ashley Sheridan wrote: The .csv format is just a plain text format, so you won't get formatting or formulas in your 'sheets' (csv is also a sheetless format) but it's been used for years by many systems for data. A lot of database systems will let you import csv files as well, which is quite convenient, although you will have to make sure the csv uses commas to delimit the data. Microsoft managed to basterdise this format a bit as well, and lets you use tabs, spaces and all sorts of other characters to delimit data fields. Someone obviously didn't mention to them that the file type is 'comma separated values'! Thanks, Ash Ash: I remember many years ago I had a problem with M$ version of plain text csv files -- the first cell of each spreadsheet was different than all other cells. It took me a while to discover that difference and build in an exception. I've found that M$ always has a better idea, even if they are the only ones who think so. 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] best way to determine mime type of file these days?
At 8:52 AM +0100 3/18/10, Per Jessen wrote: Robert P. J. Day wrote: i realize it sounds trivial but the online info is annoyingly recursive. there's mime_content_type(), but it's officially deprecated. On the manual page there is a reference to the Fileinfo PECL extension: http://php/manual/en/ref.fileinfo.php Broken. 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] protecting pages with a login system
On Thu, 2010-03-18 at 11:40 -0400, David Mehler wrote: Hi, I am wanting to protect some pages by requiring a user to log in to access them. I'd prefer this be as simple as possible, and without requiring a database. So for example when a user goes to www.domain.com/example.php they'll get a page prompting for their log in credentials, and only after providing them will the page display. I'd prefer to avoid basic authentication dialog boxes if possible. Suggestions appreciated. Thanks. Dave. By basic authentication dialog boxes, do you mean the sort that come with password protection added through the use of an .htaccess file? If that's the case, then you're left with authenticating the same way you'd do it with a database, but using some sort of flat file storage. Ideally, this flat file would be kept out of your web root for protection. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] best way to determine mime type of file these days?
tedd wrote: At 8:52 AM +0100 3/18/10, Per Jessen wrote: Robert P. J. Day wrote: i realize it sounds trivial but the online info is annoyingly recursive. there's mime_content_type(), but it's officially deprecated. On the manual page there is a reference to the Fileinfo PECL extension: http://php/manual/en/ref.fileinfo.php Broken. Sorry, that was a link to my local copy. http://php.net/manual/en/ref.fileinfo.php -- Per Jessen, Zürich (14.8°C) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] protecting pages with a login system
On Thu, Mar 18, 2010 at 11:42 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Thu, 2010-03-18 at 11:40 -0400, David Mehler wrote: Hi, I am wanting to protect some pages by requiring a user to log in to access them. I'd prefer this be as simple as possible, and without requiring a database. So for example when a user goes to www.domain.com/example.php they'll get a page prompting for their log in credentials, and only after providing them will the page display. I'd prefer to avoid basic authentication dialog boxes if possible. Suggestions appreciated. Thanks. Dave. By basic authentication dialog boxes, do you mean the sort that come with password protection added through the use of an .htaccess file? If that's the case, then you're left with authenticating the same way you'd do it with a database, but using some sort of flat file storage. Ideally, this flat file would be kept out of your web root for protection. Unless you want to have only one (or another very small number) login. You can make a normal HTML form, then the code that processes the $_POST data can just compare the username and password to the correct username and password to login. You could make the valid logins into an array and compare the $_POST data to the array of valid logins. Also, look into sessions. http://us.php.net/manual/en/book.session.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Spreadsheet_Excel_Reader problem
On Thu, Mar 18, 2010 at 8:40 AM, tedd tedd.sperl...@gmail.com wrote: At 11:35 AM + 3/18/10, Ashley Sheridan wrote: The .csv format is just a plain text format, so you won't get formatting or formulas in your 'sheets' (csv is also a sheetless format) but it's been used for years by many systems for data. A lot of database systems will let you import csv files as well, which is quite convenient, although you will have to make sure the csv uses commas to delimit the data. Microsoft managed to basterdise this format a bit as well, and lets you use tabs, spaces and all sorts of other characters to delimit data fields. Someone obviously didn't mention to them that the file type is 'comma separated values'! Thanks, Ash Ash: I remember many years ago I had a problem with M$ version of plain text csv files -- the first cell of each spreadsheet was different than all other cells. It took me a while to discover that difference and build in an exception. I've found that M$ always has a better idea, even if they are the only ones who think so. Cheers, tedd -- 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 ;) Regards, Tommy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Spreadsheet_Excel_Reader problem
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Spreadsheet_Excel_Reader problem
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 Cheers, Mattias -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Spreadsheet_Excel_Reader problem
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. Also, newlines can exist within a field value, so a line in the file doesn't equate to a row of data 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. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Re: PHP in HTML code
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.
Re: [PHP] Spreadsheet_Excel_Reader problem
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP in HTML code
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
Re: [PHP] Spreadsheet_Excel_Reader problem
On Thu, Mar 18, 2010 at 04:15:33PM +, 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP in HTML code
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
Re: [PHP] Re: PHP in HTML code
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
Re: [PHP] Spreadsheet_Excel_Reader problem
On Thu, 2010-03-18 at 12:57 -0400, Paul M Foster wrote: On Thu, Mar 18, 2010 at 04:15:33PM +, 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
Re: [PHP] Re: PHP in HTML code
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
[PHP] web sniffer
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
Re: [PHP] web sniffer
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
Re: [PHP] web sniffer
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
Re: [PHP] web sniffer
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.ukwrote: 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 **
Re: [PHP] web sniffer
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
Re: [PHP] web sniffer
On Thu, Mar 18, 2010 at 6:08 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: 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
Re: [PHP] web sniffer
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 ** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: confirm subscribe to php-general@lists.php.net
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-general@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 - Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Mar 2010 01:36:38 - 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 forphp-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-fromnore...@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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php