Re: [PHP] getaddrinfo() - what is the equivalent php function?

2010-05-27 Thread Per Jessen
Per Jessen wrote:

> AFAICT, gethostbyname() only works for ipv4 addresses, so that one is
> out - dns_get_record seems to be really for dns only, i.e. it does not
> look at /etc/hosts.  Is there a hph function that essentially just
> calls getaddrinfo() ?
> 

Wow, lots of answers to that one. 

Let me rephrase it then - what is the PHP interface to the system
resolver when support for IPv6 is required?  
Again, gethostbyname() only works for IPv4 and dns_get_record is not a
resolver interface, but a DNS interface. (AFAICT). 
 

-- 
Per Jessen, Zürich (14.9°C)


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re[2]: [PHP] One more time about regexes

2010-05-27 Thread Andre Polykanine
Hello Adam,

You did understand me exactly and perfectly).
Ordering arrays is a good idea but I don't know how to do that
exactly.
For instance, there's a cypher called Polybius square. You write in
the alphabet in a grid like this:
1 a b c d e
2 f g h i j
3 k l m n o
4 p q r s t
5 u v w x y
6 z

There is a way where i/j are equal to make a 5 by 5 square but for me
it's equal since I'm working with a 33-letter Russian alphabet, so no
way to make it a perfect square.
Anyway, a letter has two coordinates and is represented by a two-digit
number. For example, E is 15, K is 21, Z is 61 and so on.
So we have a word, say, PHP. It will look like this: 412341.
What does preg_replace do? Exactly, it's searching 41, then 12, then
23, and so on.
I tried to make a loop:
$length=mb_strlen($str);
for ($i=0; $i<$length; $i+=2) {
$pair=mb_substr($str, $i, 2);
$pair=preg_replace($numbers, $letters, $str);
}

It already smells something not good, but anyway.
If I do that, I have one more problem: say, we have a phrase "PHP is
the best". So we crypt it and get:
412341 2444 452315 12154445
Then the parser begins: "41=>p, 23=>h, 41=>p, (attention!) \s2=>"
I marked a whitespace as \s so you see what happens.
I might split the string by spaces but I can't imagine what a user
inputs: it might be a dash, for example...
Sorry for such a long message but I'm really annoyed with this
preg_replace's behavior. And it's not the only one task to
accomplish...
Thanks a lot!

-- 
With best regards from Ukraine,
Andre
Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @ 
jabber.org
Yahoo! messenger: andre.polykanine; ICQ: 191749952
Twitter: m_elensule

- Original message -
From: Adam Richardson 
To: php-general@lists.php.net 
Date: Thursday, May 27, 2010, 7:56:28 AM
Subject: [PHP] One more time about regexes

On Wed, May 26, 2010 at 11:10 PM, Nilesh Govindarajan wrote:

> -- Forwarded message --
> From: Nilesh Govindarajan 
> Date: Thu, May 27, 2010 at 8:40 AM
> Subject: Re: [PHP] One more time about regexes
> To: Andre Polykanine 
>
>
> On Thu, May 27, 2010 at 3:33 AM, Andre Polykanine  wrote:
> > Hello everyone,
> >
> > Sorry, but I'm asking one more time (since it's really annoying me and
> > I need to apply some really dirty hacks):
> > Is there a way making preg_replace() pass through the regex one single
> > time searching from left to right and not to erase what it has already
> > done?
> > I can give you a real task I'm accomplishing but the tasks requiring
> > that tend to multiply...
> > Thanks a lot!
> >
> > --
> > With best regards from Ukraine,
> > Andre
> > Http://oire.org/ - The Fantasy blogs of Oire
> > Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @
> jabber.org
> > Yahoo! messenger: andre.polykanine; ICQ: 191749952
> > Twitter: http://twitter.com/m_elensule
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
> If you don't want to replace the stuff it has searched then use preg_match
> !
>
> --
> Nilesh Govindarajan
> Facebook: nilesh.gr
> Twitter: nileshgr
> Website: www.itech7.com
>
>
>
> --
> Nilesh Govindarajan
> Facebook: nilesh.gr
> Twitter: nileshgr
> Website: www.itech7.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
If I'm understanding correctly, Andre, you want to perform a replace
operation, but you're observing that there's an element of recursion
happening (e.g., you replace one item with its replacement, and then the new
replacement is also replaced.)

To my knowledge, this won't happen with a standard preg_replace():

$string = 'Bil & Tom & Phil';
$pattern = '/&/';
$replacement = '&';
// outputs Bil & Tom & Phil
echo preg_replace($pattern, $replacement, $string);

However, if you're using arrays to pass in the patterns and replacements,
then one array item could later be replaced by another (see comment and
example on this page by info at gratisrijden dot nl):
http://php.net/manual/en/function.preg-replace.php

If that's the case, you have to carefully structure the order of the array
items so-as to preclude one replacement having the opportunity to override a
subsequent replacement.

Sorry if I misunderstood.  You might want to create a simple example of code
showing what you're working through.

Adam


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


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: Re[2]: [PHP] One more time about regexes

2010-05-27 Thread Ford, Mike


> -Original Message-
> From: Andre Polykanine [mailto:an...@oire.org]
> Sent: 27 May 2010 09:14
> To: Adam Richardson
> Cc: php-general@lists.php.net
> Subject: Re[2]: [PHP] One more time about regexes
> 
> Hello Adam,
> 
> You did understand me exactly and perfectly).
> Ordering arrays is a good idea but I don't know how to do that
> exactly.
> For instance, there's a cypher called Polybius square. You write in
> the alphabet in a grid like this:
> 1 a b c d e
> 2 f g h i j
> 3 k l m n o
> 4 p q r s t
> 5 u v w x y
> 6 z
> 
> There is a way where i/j are equal to make a 5 by 5 square but for
> me
> it's equal since I'm working with a 33-letter Russian alphabet, so
> no
> way to make it a perfect square.
> Anyway, a letter has two coordinates and is represented by a two-
> digit
> number. For example, E is 15, K is 21, Z is 61 and so on.
> So we have a word, say, PHP. It will look like this: 412341.

Well, as you're wanting to replace pairs of digits, I'd search for exactly that 
-- but I think I'd use the e flag to employ a programmed replacement, thus:

$str = "4123415 - 2444 452315 12154445!";
$replaced = preg_replace("{(\d\d)}e", "polybius_decode('\\1')", $str);

echo $replaced;

function polybius_decode($pair) {

   static $polybius = array(
  '11'=>'a', 'b', 'c', 'd', 'e',
  '21'=>'f', 'g', 'h', 'i', 'j',
  '31'=>'k', 'l', 'm', 'n', 'o',
  '41'=>'p', 'q', 'r', 's', 't',
  '51'=>'u', 'v', 'w', 'x', 'y',
  '61'=>'z'
   );

   return isset($polybius[$pair]) ? $polybius[$pair] : $pair;
}

Seems to work: "php5 - is the best!". :)

Cheers!

Mike
 -- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Leeds Metropolitan University, C507, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom 
Email: m.f...@leedsmet.ac.uk 
Tel: +44 113 812 4730





To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Convert UTF-8 to PHP defines

2010-05-27 Thread Andre Polykanine
Hello Guus,

Actually, we are using the same method here on http://oire.org/. We
have all of the language files in UTF8 format and everything seems to
be OK. Yes, unicode support in PHp laisse à désirer, like the French
say, but it does support UTF8 files.
-- 
With best regards from Ukraine,
Andre
Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @ 
jabber.org
Yahoo! messenger: andre.polykanine; ICQ: 191749952
Twitter: m_elensule

- Original message -
From: Guus Ellenkamp 
To: php-general@lists.php.net 
Date: Wednesday, May 26, 2010, 5:20:59 PM
Subject: [PHP] Convert UTF-8 to PHP defines

We use PHP defines for defining text in different languages. As far as I 
know PHP files are supposed to be ASCII, not UTF-8 or something like that. 
What I want to make is a conversion program that would convert a given UTF-8 
file with the format

definetext1=this is a text in random UTF-8, probably arabic or similar text
definetext2=this is another text in random UTF-8, probably arabic or similar 
text

into a file with the following defines

define('definetext1',chr().chr().chr()...).chr());
define('definetext2,chr().chr().chr()...).chr());

Not sure if I'm using the correct chr/ord function, but I hope the above is 
clear enough to make clear what I'm looking for. Basically the output file 
should be ascii and not contain any utf-8.

Any advise? The html_special_chars did not seem to work for Vietnamese text 
I tried to convert, so something seems to get wrong with just reading an 
array of strings and converting the strings and putting them in defines. 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Convert UTF-8 to PHP defines

2010-05-27 Thread Guus Ellenkamp
Thanks, but are you sure of that? I did some research a while ago and found 
that officially PHP files should be ascii and not have any specific 
character encoding. I believe it will work anyhow (did not try this one), 
but would like to stick with the standards.

"Ashley Sheridan"  wrote in message 
news:1274883714.2202.228.ca...@localhost...
> On Wed, 2010-05-26 at 22:20 +0800, Guus Ellenkamp wrote:
>
>> We use PHP defines for defining text in different languages. As far as I
>> know PHP files are supposed to be ASCII, not UTF-8 or something like 
>> that.
>> What I want to make is a conversion program that would convert a given 
>> UTF-8
>> file with the format
>>
>> definetext1=this is a text in random UTF-8, probably arabic or similar 
>> text
>> definetext2=this is another text in random UTF-8, probably arabic or 
>> similar
>> text
>>
>> into a file with the following defines
>>
>> define('definetext1',chr().chr().chr()...).chr());
>> define('definetext2,chr().chr().chr()...).chr());
>>
>> Not sure if I'm using the correct chr/ord function, but I hope the above 
>> is
>> clear enough to make clear what I'm looking for. Basically the output 
>> file
>> should be ascii and not contain any utf-8.
>>
>> Any advise? The html_special_chars did not seem to work for Vietnamese 
>> text
>> I tried to convert, so something seems to get wrong with just reading an
>> array of strings and converting the strings and putting them in defines.
>>
>>
>>
>
>
> PHP files can contain utf-8, and in-fact is the preference of most
> developers I know of.
>
> 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] Convert UTF-8 to PHP defines

2010-05-27 Thread Ashley Sheridan
On Thu, 2010-05-27 at 21:45 +0800, Guus Ellenkamp wrote:

> Thanks, but are you sure of that? I did some research a while ago and found 
> that officially PHP files should be ascii and not have any specific 
> character encoding. I believe it will work anyhow (did not try this one), 
> but would like to stick with the standards.
> 
> "Ashley Sheridan"  wrote in message 
> news:1274883714.2202.228.ca...@localhost...
> > On Wed, 2010-05-26 at 22:20 +0800, Guus Ellenkamp wrote:
> >
> >> We use PHP defines for defining text in different languages. As far as I
> >> know PHP files are supposed to be ASCII, not UTF-8 or something like 
> >> that.
> >> What I want to make is a conversion program that would convert a given 
> >> UTF-8
> >> file with the format
> >>
> >> definetext1=this is a text in random UTF-8, probably arabic or similar 
> >> text
> >> definetext2=this is another text in random UTF-8, probably arabic or 
> >> similar
> >> text
> >>
> >> into a file with the following defines
> >>
> >> define('definetext1',chr().chr().chr()...).chr());
> >> define('definetext2,chr().chr().chr()...).chr());
> >>
> >> Not sure if I'm using the correct chr/ord function, but I hope the above 
> >> is
> >> clear enough to make clear what I'm looking for. Basically the output 
> >> file
> >> should be ascii and not contain any utf-8.
> >>
> >> Any advise? The html_special_chars did not seem to work for Vietnamese 
> >> text
> >> I tried to convert, so something seems to get wrong with just reading an
> >> array of strings and converting the strings and putting them in defines.
> >>
> >>
> >>
> >
> >
> > PHP files can contain utf-8, and in-fact is the preference of most
> > developers I know of.
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> > 
> 
> 
> 


Very sure, ever PHP file I ever make is always in utf8. The only problem
you might encounter is when outputting HTML, you should make sure that
you output the right text encoding headers, as some browsers won't
correctly detect it and can tend to output utf-8 characters as random
blocks and other characters.

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




[PHP] uploading file encoding error

2010-05-27 Thread Manolis Vlachakis
hallo there everyone!
i am uploading a file in a php applet i developed and i face a problem
while i upload greek named files..
have no problem with the english or so on files...
is there a way to use iconv or something else so as to solve my problem ?
my code looks like that...


$uploaddir = $_SERVER['DOCUMENT_ROOT'] . '/
//public_html/uploads/';
$file = $uploaddir . basename($_FILES['uploadfile']['name']);
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) {
  echo "success";
} else {
echo "error";
}



thanx

-- 
Manolis Vlachakis

Nelly's Family Hotel
Visit:   www.nellys-hotel.gr
  www.nellys.gr
Skype : manolis.vlachakis


Re: [PHP] uploading file encoding error

2010-05-27 Thread Ashley Sheridan
On Thu, 2010-05-27 at 17:49 +0300, Manolis Vlachakis wrote:

> hallo there everyone!
> i am uploading a file in a php applet i developed and i face a problem
> while i upload greek named files..
> have no problem with the english or so on files...
> is there a way to use iconv or something else so as to solve my problem ?
> my code looks like that...
> 
> 
> $uploaddir = $_SERVER['DOCUMENT_ROOT'] . '/
> //public_html/uploads/';
> $file = $uploaddir . basename($_FILES['uploadfile']['name']);
> if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) {
>   echo "success";
> } else {
> echo "error";
> }
> 
> 
> 
> thanx
> 


I assume that the file upload works with other files?

Firstly, what is the filesystem that you're using, and the operating
system. Windows filesystems are very limiting on what characters you can
use.

If you have it working with another file, have you tried renaming that
to use characters which you think are causing the problems?

Lastly, what exactly is the error code returned from the $_FILES array?

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




Re: [PHP] uploading file encoding error

2010-05-27 Thread Ashley Sheridan
On Thu, 2010-05-27 at 18:03 +0300, Manolis Vlachakis wrote:

> i am using gentoo
> 
> and on the server side i cant see either the files with their greek
> names
> but i had no problem in the past handling them even though
> i couldn't see them...
> 
> 
> my servers log say that they uploaded the file but no
> error occurred...
> is there another way to upload a file with that script or i should try
> to find something else to solve my problem

[/SNIP]

> 
> 
> -- 
> Manolis Vlachakis
> 
> Nelly's Family Hotel 
> Visit:   www.nellys-hotel.gr
>   www.nellys.gr
> Skype : manolis.vlachakis
> 

Gentoo I believe uses the ext3 filesystem by default, which should be
perfectly capable of handling Greek characters.

What happens when you upload a normal small file now with non-Greek
characters and see what happens? Does that upload correctly?

Output the $_FILES array and look to see if the error code is anything
other than 0. If it is, that means there's a problem with the upload,
which probably won't show on the server log.

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




[PHP] Method documentation

2010-05-27 Thread la...@garfieldtech.com

Hi folks.

OK, so here's the deal.  I am trying to figure out the "right" way to 
document methods in OO code that includes method overriding in child 
classes.  Simple, right?  Unfortunately, it seems the tools out there 
are making this much more complicated than it should be.  Example:


class Foo {

  /**
   * Says hello.
   *
   * Lengthier description of this method.
   *
   * @param int $a
   *   The first variable.
   * @param int $b
   *   The second variable.
   * @return string
   *   A message.
   *
   */
  public function hello($a, $b) { /* ... */ }
}

class Bar extends Foo {
  public function hello($a, $b) { /* ... */ }
}

Seems simple, right?  Here's the problem(s):

- If I put no docblock on Bar::hello(), every IDE I've tried shows no 
documentation whatsoever when I do $b = new Bar; $b->he...  It will 
auto-complete, but does not provide any documentation.  Documentation 
parsers (PHPDoc, Doxygen, etc.) will detect that and show the parent 
method's docblock, however, and it's easy to maintain.


- If I put no docblock on Bar::hello(), someone just reading the code 
visually has no idea what the method does, or what parent class or 
interface it comes from that might contain documentation.


- If I put a subset of the documentation on Bar::hello, an IDE shows 
only that subset, which is frequently inadequate.  Documentation parsers 
also, as far as I know, will then only show the abridged version.


- If I duplicate the documentation on Bar::hello(), it shows up in an 
IDE and is there for people reading it, but it still doesn't say what 
interface or parent class it comes from.


- If I duplicate the documentation on Bar::hello(), that's a ton of 
duplicate content that I will then have to always keep in sync as the 
system evolves.  (Rather, that everyone will have to as this is a large 
multi-person project.)


- If I make a docblock that is just a "Overrides Foo::hello()", then 
it's easy to maintain and there's no duplication, but the IDE assistance 
is useless and the documentation parsers I know of will all show that as 
the only description, which is not all that useful.



So it seems like no matter what I do, someone gets totally screwed with 
useless documentation (either IDE users, plain text editor users, 
code/documentation maintainers, or people looking at the documentation 
online in Doxygen or PHPDoc).  Is there an alternative I'm missing that 
doesn't suck?  What do most people do to deal with this trainwreck?


--Larry Garfield

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Method documentation

2010-05-27 Thread Peter Lind
On 27 May 2010 17:15, la...@garfieldtech.com  wrote:
> Hi folks.
>
> OK, so here's the deal.  I am trying to figure out the "right" way to
> document methods in OO code that includes method overriding in child
> classes.  Simple, right?  Unfortunately, it seems the tools out there are
> making this much more complicated than it should be.  Example:
>
> class Foo {
>
>  /**
>   * Says hello.
>   *
>   * Lengthier description of this method.
>   *
>   * @param int $a
>   *   The first variable.
>   * @param int $b
>   *   The second variable.
>   * @return string
>   *   A message.
>   *
>   */
>  public function hello($a, $b) { /* ... */ }
> }
>
> class Bar extends Foo {
>  public function hello($a, $b) { /* ... */ }
> }
>
> Seems simple, right?  Here's the problem(s):
>
> - If I put no docblock on Bar::hello(), every IDE I've tried shows no
> documentation whatsoever when I do $b = new Bar; $b->he...  It will
> auto-complete, but does not provide any documentation.  Documentation
> parsers (PHPDoc, Doxygen, etc.) will detect that and show the parent
> method's docblock, however, and it's easy to maintain.

You're overriding the function. IDEs should *not* show the parent
documentation, because the parent function does *not* get called. It
only gets called if you do a specific parent::hello($a, $b);

> - If I put no docblock on Bar::hello(), someone just reading the code
> visually has no idea what the method does, or what parent class or interface
> it comes from that might contain documentation.

Again, the function doesn't come from a parent. The user should read
the function they're looking at to find out what it does. Checking the
overridden function only makes sense if it's explicitly called.

> - If I put a subset of the documentation on Bar::hello, an IDE shows only
> that subset, which is frequently inadequate.  Documentation parsers also, as
> far as I know, will then only show the abridged version.
>
> - If I duplicate the documentation on Bar::hello(), it shows up in an IDE
> and is there for people reading it, but it still doesn't say what interface
> or parent class it comes from.

I honestly don't see why one would ever want this information. You're
defining the function in the current class - whether or not it's
defined in the parent class has no effect on what function you'll get
when you call an object of *this* class.

> - If I duplicate the documentation on Bar::hello(), that's a ton of
> duplicate content that I will then have to always keep in sync as the system
> evolves.  (Rather, that everyone will have to as this is a large
> multi-person project.)

Then document the parent method as being a stub that should be
overridden. Document the overriding method - which presumably has
actual code in it - properly.

> - If I make a docblock that is just a "Overrides Foo::hello()", then it's
> easy to maintain and there's no duplication, but the IDE assistance is
> useless and the documentation parsers I know of will all show that as the
> only description, which is not all that useful.

IDE assistance would always be useless: if you're overriding the
parent method it *has* to be because the behaviour is different than
from the method in the parent class. Hence, the method should have
it's own documentation - otherwise, why bother with documentation at
all?

>
> So it seems like no matter what I do, someone gets totally screwed with
> useless documentation (either IDE users, plain text editor users,
> code/documentation maintainers, or people looking at the documentation
> online in Doxygen or PHPDoc).  Is there an alternative I'm missing that
> doesn't suck?  What do most people do to deal with this trainwreck?
>

Personally, I think this issue stems from a wrong way of thinking
about methods and overriding them. You're either not documenting the
overriding methods properly or overriding methods for no real reason.
At least, that's how it looks from here (and my apologies if I got it
completely wrong :) ).

Regards
Peter

-- 

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Method documentation

2010-05-27 Thread la...@garfieldtech.com

On 5/27/10 10:43 AM, Peter Lind wrote:


You're overriding the function. IDEs should *not* show the parent
documentation, because the parent function does *not* get called. It
only gets called if you do a specific parent::hello($a, $b);


*snip*


So it seems like no matter what I do, someone gets totally screwed with
useless documentation (either IDE users, plain text editor users,
code/documentation maintainers, or people looking at the documentation
online in Doxygen or PHPDoc).  Is there an alternative I'm missing that
doesn't suck?  What do most people do to deal with this trainwreck?



Personally, I think this issue stems from a wrong way of thinking
about methods and overriding them. You're either not documenting the
overriding methods properly or overriding methods for no real reason.
At least, that's how it looks from here (and my apologies if I got it
completely wrong :) ).

Regards
Peter


I'm overriding the method because I want to change the *implementation*. 
 The *interface* of it, which is documented in the docblock, should not 
change and it's a bug (and possibly compile error) if it does change. 
You cannot, for instance, change what parameters the method takes in a 
subclass.  If you change the meaning of those parameters then you're 
setting yourself up for crazy and hard to debug bugs.  So the @param 
documentation absolutely should be the same for both.


To wit:

interface Talk {
  /**
   * Prints a message in the appropriate language.
   *
   * @param $message
   *   A key indicating the message to pull from the DB
   *   and print.
   * @return boolean
   *   TRUE if it worked, FALSE otherwise.
   */
  public function hello($message) {}
}

class TalkInSpanish implements Talk {
  public function hello($message) {}
}

class TalkInKlingon implments Talk {
  public function hello($message) {}
}

The documentation for both concrete implementations is identical.  If 
$message means something different for the Klingon implementation, or if 
the return changes, then that's a critical bug.  You're breaking the 
interface.


But if I do:

$talk = resolve_language();
$talk->hello(...

Then I should get code assistance, and my doc parser should show useful 
information for TalkInKlingon::hello(), and someone just reading 
TalkInKlingon (which may be in a different file than Talk) should be 
able to easily figure out what $message means.


As of yet, I've not figured out a way to get all three that doesn't 
involve tons of repeated copying and pasting and wasting time and lines.


--Larry Garfield

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Convert UTF-8 to PHP defines

2010-05-27 Thread Adam Richardson
On Thu, May 27, 2010 at 9:45 AM, Guus Ellenkamp
wrote:

> Thanks, but are you sure of that? I did some research a while ago and found
> that officially PHP files should be ascii and not have any specific
> character encoding. I believe it will work anyhow (did not try this one),
> but would like to stick with the standards.
>
> "Ashley Sheridan"  wrote in message
> news:1274883714.2202.228.ca...@localhost...
> > On Wed, 2010-05-26 at 22:20 +0800, Guus Ellenkamp wrote:
> >
> >> We use PHP defines for defining text in different languages. As far as I
> >> know PHP files are supposed to be ASCII, not UTF-8 or something like
> >> that.
> >> What I want to make is a conversion program that would convert a given
> >> UTF-8
> >> file with the format
> >>
> >> definetext1=this is a text in random UTF-8, probably arabic or similar
> >> text
> >> definetext2=this is another text in random UTF-8, probably arabic or
> >> similar
> >> text
> >>
> >> into a file with the following defines
> >>
> >>
> define('definetext1',chr().chr().chr()...).chr());
> >>
> define('definetext2,chr().chr().chr()...).chr());
> >>
> >> Not sure if I'm using the correct chr/ord function, but I hope the above
> >> is
> >> clear enough to make clear what I'm looking for. Basically the output
> >> file
> >> should be ascii and not contain any utf-8.
> >>
> >> Any advise? The html_special_chars did not seem to work for Vietnamese
> >> text
> >> I tried to convert, so something seems to get wrong with just reading an
> >> array of strings and converting the strings and putting them in defines.
> >>
> >>
> >>
> >
> >
> > PHP files can contain utf-8, and in-fact is the preference of most
> > developers I know of.
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> >
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Because the lower range of UTF-8 matches the ascii character set
(intentionally by design), you'll be able to use UTF-8 for PHP files without
problem (i.e., ascii 7-bit chars have same encoding in UTF-8.)
http://www.cl.cam.ac.uk/~mgk25/unicode.html

However, if you were to use any of the multibyte characters of UTF-8 in a
PHP file, you could run in to some trouble.  I use UTF-8 for most of my PHP
files, but I've been sticking to the ASCII subset exclusively.

Adam

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


Re: [PHP] Convert UTF-8 to PHP defines

2010-05-27 Thread Ashley Sheridan
On Thu, 2010-05-27 at 12:08 -0400, Adam Richardson wrote:

> On Thu, May 27, 2010 at 9:45 AM, Guus Ellenkamp
> wrote:
> 
> > Thanks, but are you sure of that? I did some research a while ago and found
> > that officially PHP files should be ascii and not have any specific
> > character encoding. I believe it will work anyhow (did not try this one),
> > but would like to stick with the standards.
> >
> > "Ashley Sheridan"  wrote in message
> > news:1274883714.2202.228.ca...@localhost...
> > > On Wed, 2010-05-26 at 22:20 +0800, Guus Ellenkamp wrote:
> > >
> > >> We use PHP defines for defining text in different languages. As far as I
> > >> know PHP files are supposed to be ASCII, not UTF-8 or something like
> > >> that.
> > >> What I want to make is a conversion program that would convert a given
> > >> UTF-8
> > >> file with the format
> > >>
> > >> definetext1=this is a text in random UTF-8, probably arabic or similar
> > >> text
> > >> definetext2=this is another text in random UTF-8, probably arabic or
> > >> similar
> > >> text
> > >>
> > >> into a file with the following defines
> > >>
> > >>
> > define('definetext1',chr().chr().chr()...).chr());
> > >>
> > define('definetext2,chr().chr().chr()...).chr());
> > >>
> > >> Not sure if I'm using the correct chr/ord function, but I hope the above
> > >> is
> > >> clear enough to make clear what I'm looking for. Basically the output
> > >> file
> > >> should be ascii and not contain any utf-8.
> > >>
> > >> Any advise? The html_special_chars did not seem to work for Vietnamese
> > >> text
> > >> I tried to convert, so something seems to get wrong with just reading an
> > >> array of strings and converting the strings and putting them in defines.
> > >>
> > >>
> > >>
> > >
> > >
> > > PHP files can contain utf-8, and in-fact is the preference of most
> > > developers I know of.
> > >
> > > Thanks,
> > > Ash
> > > http://www.ashleysheridan.co.uk
> > >
> > >
> > >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> Because the lower range of UTF-8 matches the ascii character set
> (intentionally by design), you'll be able to use UTF-8 for PHP files without
> problem (i.e., ascii 7-bit chars have same encoding in UTF-8.)
> http://www.cl.cam.ac.uk/~mgk25/unicode.html
> 
> However, if you were to use any of the multibyte characters of UTF-8 in a
> PHP file, you could run in to some trouble.  I use UTF-8 for most of my PHP
> files, but I've been sticking to the ASCII subset exclusively.
> 
> Adam
> 


I don't use the higher range of characters often, but I do sometimes use
them for things like the graphical glyphs (½✉✆, etc) I know I could do
those with regular text and the Wingdings font, but that's not available
on every computer, and breaks the semantic meaning behind the glyphs.

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




Re: [PHP] Method documentation

2010-05-27 Thread Peter Lind
On 27 May 2010 17:57, la...@garfieldtech.com  wrote:
> On 5/27/10 10:43 AM, Peter Lind wrote:
>
>> You're overriding the function. IDEs should *not* show the parent
>> documentation, because the parent function does *not* get called. It
>> only gets called if you do a specific parent::hello($a, $b);
>
> *snip*
>
>>> So it seems like no matter what I do, someone gets totally screwed with
>>> useless documentation (either IDE users, plain text editor users,
>>> code/documentation maintainers, or people looking at the documentation
>>> online in Doxygen or PHPDoc).  Is there an alternative I'm missing that
>>> doesn't suck?  What do most people do to deal with this trainwreck?
>>>
>>
>> Personally, I think this issue stems from a wrong way of thinking
>> about methods and overriding them. You're either not documenting the
>> overriding methods properly or overriding methods for no real reason.
>> At least, that's how it looks from here (and my apologies if I got it
>> completely wrong :) ).
>>
>> Regards
>> Peter
>
> I'm overriding the method because I want to change the *implementation*.
>  The *interface* of it, which is documented in the docblock, should not
> change and it's a bug (and possibly compile error) if it does change. You
> cannot, for instance, change what parameters the method takes in a subclass.
>  If you change the meaning of those parameters then you're setting yourself
> up for crazy and hard to debug bugs.  So the @param documentation absolutely
> should be the same for both.
>

Sure, but @param, @access and possibly @return are but a part. I stand
by my words: document the parent as a stub and provide actual
documentation for the real implementations. Otherwise you're trying to
be *clever* and will see the age-old result: you'll end up shooting
yourself in the foot or worse places.

Regards
Peter

-- 

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Method documentation

2010-05-27 Thread la...@garfieldtech.com

On 5/27/10 11:13 AM, Peter Lind wrote:


I'm overriding the method because I want to change the *implementation*.
  The *interface* of it, which is documented in the docblock, should not
change and it's a bug (and possibly compile error) if it does change. You
cannot, for instance, change what parameters the method takes in a subclass.
  If you change the meaning of those parameters then you're setting yourself
up for crazy and hard to debug bugs.  So the @param documentation absolutely
should be the same for both.



Sure, but @param, @access and possibly @return are but a part. I stand
by my words: document the parent as a stub and provide actual
documentation for the real implementations. Otherwise you're trying to
be *clever* and will see the age-old result: you'll end up shooting
yourself in the foot or worse places.

Regards
Peter


... What's "clever" about using OO inheritance the way it's designed to 
be used?  Are you actually suggesting that the solution is to insist on 
duplicating the docblock in every child class, which is a huge 
maintenance headache?


I could go through a dozen other examples where this problem exists 
where there's nothing "clever" (when that became an epithet I don't 
know) going on, just rudimentary OO, but I won't clog the list with it. 
 What I'm doing in the previous examples is in no way esoteric.  This 
is OO 101 code.


--Larry Garfield

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-27 Thread tedd

At 3:50 PM -0400 5/26/10, Alice Wei wrote:


   My bad, I cannot imagine I sent that stuff. To answer your 
question, here it is,



Select the type of your starting point of interest:
 maxlength="50"/>


   
   


This is what is working now if I do it this way, but again, then I 
got to make sure everything is "typed up properly" before the form 
is submitted. Does this answer your questions by any chance?



Alice



Alice:

Okay, not bad -- here's my addition:

http://www.webbytedd.com//alice/

Please review the code. I removed the maxlength because that's 
something you should do server-side anyway. Never trust anything 
coming from the client-side.


Also note that closing the tags, such as  is optional -- IF -- 
you're not planning on using XML. Otherwise they will generate a W3C 
short-tags warning. However, that's not a fatal error.


Also note the Submit button statement has three attributes. Type 
states the type of input statement, value is what the button displays 
to the user (i.e., Submit") and name is the name of the variable that 
you can access via a POST/GET.


Also note how the form collects the "start" value from a POST and 
then repopulates the form after it has the data. This important to 
understand. Clicking the "Submit" button sends the form's data to the 
server which then sends it back to the browser via a refreshed form.


Also note the ternary operator I used, namely:

$start = isset($_POST['start']) ? $_POST['start'] : null;

The first time the page is viewed, POST is sampled for content. If 
there is no content, then checking for content will generate an error 
unless we first check to see if it has content, hence the isset(). If 
it doesn't have content, then the statement assigns NULL to $start. 
If it does have content, then it will assign that value to $start, 
understand?


Now, what's next? What other data do you want to collect? You 
mentioned a select control that derived its data from a database. But 
before we go to that, show me a "select" control working in a form 
with embedded values -- in other words, just a simple select control. 
Please add it to the form we have.


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] Method documentation

2010-05-27 Thread Peter Lind
On 27 May 2010 18:21, la...@garfieldtech.com  wrote:
> On 5/27/10 11:13 AM, Peter Lind wrote:
>
>>> I'm overriding the method because I want to change the *implementation*.
>>>  The *interface* of it, which is documented in the docblock, should not
>>> change and it's a bug (and possibly compile error) if it does change. You
>>> cannot, for instance, change what parameters the method takes in a
>>> subclass.
>>>  If you change the meaning of those parameters then you're setting
>>> yourself
>>> up for crazy and hard to debug bugs.  So the @param documentation
>>> absolutely
>>> should be the same for both.
>>>
>>
>> Sure, but @param, @access and possibly @return are but a part. I stand
>> by my words: document the parent as a stub and provide actual
>> documentation for the real implementations. Otherwise you're trying to
>> be *clever* and will see the age-old result: you'll end up shooting
>> yourself in the foot or worse places.
>>
>> Regards
>> Peter
>
> ... What's "clever" about using OO inheritance the way it's designed to be
> used?  Are you actually suggesting that the solution is to insist on
> duplicating the docblock in every child class, which is a huge maintenance
> headache?

If the implementations are the same in all child classes, then you're
doing OO horribly wrong. If they're *not* the same, then you'll merely
be duplicating a part of the documentation (docblocks do *not* just
consist of @param and @access) while writing the rest of the
documentation to show what you're actually doing different in each
method.

> I could go through a dozen other examples where this problem exists where
> there's nothing "clever" (when that became an epithet I don't know) going
> on, just rudimentary OO, but I won't clog the list with it.  What I'm doing
> in the previous examples is in no way esoteric.  This is OO 101 code.

I honestly doubt you're doing things optimally, if you're having
problems this big. I've never come across this problem, but maybe
that's just me.
 Anyway, I don't have other advice to offer, so I'll refrain from
posting again, as I'm obviously not helping you.

Regards
Peter

-- 

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Convert UTF-8 to PHP defines

2010-05-27 Thread tedd

At 5:13 PM +0100 5/27/10, Ashley Sheridan wrote:


I don't use the higher range of characters often, but I do sometimes use
them for things like the graphical glyphs (1Ž2)&, etc) I know I could do
those with regular text and the Wingdings font, but that's not available
on every computer, and breaks the semantic meaning behind the glyphs.

Thanks,
Ash



Ash:

I read briefly on the css discuss list there is a 
movement to "force" download of fonts (i.e., char 
sets) to make layouts work. Apparently some 
browsers allow for that but I have not read up on 
it and I may have the wrong impression, but that 
was my take.


For the exception of "evil" fonts, it seemed like a good idea.

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] Method documentation

2010-05-27 Thread la...@garfieldtech.com

On 5/27/10 11:30 AM, Peter Lind wrote:


Sure, but @param, @access and possibly @return are but a part. I stand
by my words: document the parent as a stub and provide actual
documentation for the real implementations. Otherwise you're trying to
be *clever* and will see the age-old result: you'll end up shooting
yourself in the foot or worse places.

Regards
Peter


... What's "clever" about using OO inheritance the way it's designed to be
used?  Are you actually suggesting that the solution is to insist on
duplicating the docblock in every child class, which is a huge maintenance
headache?


If the implementations are the same in all child classes, then you're
doing OO horribly wrong.


Of course the implementations aren't the same.  That would be silly. 
But the API is the same, by design.



If they're *not* the same, then you'll merely
be duplicating a part of the documentation (docblocks do *not* just
consist of @param and @access) while writing the rest of the
documentation to show what you're actually doing different in each
method.


I generally do not put a description of the entire internal algorithm 
into the docblock, as that is not part of the API.  That's also by 
design.  Even if there is implementation-specific stuff to add, the 
"short description line", @params, @return, and lots of other things 
don't change, nor should they.  So at best you're duplicating half the 
docblock each time.  Still a high maintenance burden.


--Larry Garfield

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Method documentation

2010-05-27 Thread Richard Quadling
On 27 May 2010 17:21, la...@garfieldtech.com  wrote:
> On 5/27/10 11:13 AM, Peter Lind wrote:
>
>>> I'm overriding the method because I want to change the *implementation*.
>>>  The *interface* of it, which is documented in the docblock, should not
>>> change and it's a bug (and possibly compile error) if it does change. You
>>> cannot, for instance, change what parameters the method takes in a
>>> subclass.
>>>  If you change the meaning of those parameters then you're setting
>>> yourself
>>> up for crazy and hard to debug bugs.  So the @param documentation
>>> absolutely
>>> should be the same for both.
>>>
>>
>> Sure, but @param, @access and possibly @return are but a part. I stand
>> by my words: document the parent as a stub and provide actual
>> documentation for the real implementations. Otherwise you're trying to
>> be *clever* and will see the age-old result: you'll end up shooting
>> yourself in the foot or worse places.
>>
>> Regards
>> Peter
>
> ... What's "clever" about using OO inheritance the way it's designed to be
> used?  Are you actually suggesting that the solution is to insist on
> duplicating the docblock in every child class, which is a huge maintenance
> headache?
>
> I could go through a dozen other examples where this problem exists where
> there's nothing "clever" (when that became an epithet I don't know) going
> on, just rudimentary OO, but I won't clog the list with it.  What I'm doing
> in the previous examples is in no way esoteric.  This is OO 101 code.
>
> --Larry Garfield
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Just because the params and return type are the same, you would have
to document the methods purpose. So may as well include the params and
return.



There is the 
http://manual.phpdoc.org/HTMLframesConverter/phphtmllib/phpDocumentor/tutorial_tags.inlineinheritdoc.pkg.html
which will allow you pull in the description...

Ideally there needs to be something like an inheritparams,
inheritreturn and maybe inheritall.

You also have 
http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_phpDocumentor.howto.pkg.html#basics.docblocktemplate,
but I can't see how that is useful beyond a single class. By that I
mean, I don't think you can clone the content of one docblock in the
interface into the docblock of the class.

But overall, I agree with Peter.

Richard

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Method documentation

2010-05-27 Thread Adam Richardson
On Thu, May 27, 2010 at 12:44 PM, la...@garfieldtech.com <
la...@garfieldtech.com> wrote:

> On 5/27/10 11:30 AM, Peter Lind wrote:
>
>  Sure, but @param, @access and possibly @return are but a part. I stand
 by my words: document the parent as a stub and provide actual
 documentation for the real implementations. Otherwise you're trying to
 be *clever* and will see the age-old result: you'll end up shooting
 yourself in the foot or worse places.

 Regards
 Peter

>>>
>>> ... What's "clever" about using OO inheritance the way it's designed to
>>> be
>>> used?  Are you actually suggesting that the solution is to insist on
>>> duplicating the docblock in every child class, which is a huge
>>> maintenance
>>> headache?
>>>
>>
>> If the implementations are the same in all child classes, then you're
>> doing OO horribly wrong.
>>
>
> Of course the implementations aren't the same.  That would be silly. But
> the API is the same, by design.
>
>
>  If they're *not* the same, then you'll merely
>> be duplicating a part of the documentation (docblocks do *not* just
>> consist of @param and @access) while writing the rest of the
>> documentation to show what you're actually doing different in each
>> method.
>>
>
> I generally do not put a description of the entire internal algorithm into
> the docblock, as that is not part of the API.  That's also by design.  Even
> if there is implementation-specific stuff to add, the "short description
> line", @params, @return, and lots of other things don't change, nor should
> they.  So at best you're duplicating half the docblock each time.  Still a
> high maintenance burden.
>
> --Larry Garfield
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Larry,

I've thought about this very issue before (java developers sometimes lament
this issue, too), and I error on the side of duplication if I'm using
inheritance.

However, I'd say I rarely use inheritance for anything in my development,
and I'm much more likely to use composition.

When a project evolves that's built almost entirely using design patterns
focused on composition, I find that I very rarely have to duplicate any
documentation, or rework documentation later on because a completely new
component is being used.

Outside of PHP (Scala, Objective C, F#, etc.), it seems like inheritance is
advocated much less frequently, due to the power and simplicity of
composition (e.g., change behavior at runtime, requires less knowledge of
the parent classes.)

Quoting the Head First book on design patterns:
"Favor composition over inheritance"

Now, there are situations where either inheritance is the most appropriate,
and/or the architecture is not directly under your control.  And, as I said
at the beginning, I tend to error on the side of duplication.  I just try to
never put myself in that situation :)

Adam

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


Re: [PHP] Method documentation

2010-05-27 Thread la...@garfieldtech.com

On 5/27/10 12:10 PM, Adam Richardson wrote:


Larry,

I've thought about this very issue before (java developers sometimes lament
this issue, too), and I error on the side of duplication if I'm using
inheritance.

However, I'd say I rarely use inheritance for anything in my development,
and I'm much more likely to use composition.

When a project evolves that's built almost entirely using design patterns
focused on composition, I find that I very rarely have to duplicate any
documentation, or rework documentation later on because a completely new
component is being used.

Outside of PHP (Scala, Objective C, F#, etc.), it seems like inheritance is
advocated much less frequently, due to the power and simplicity of
composition (e.g., change behavior at runtime, requires less knowledge of
the parent classes.)

Quoting the Head First book on design patterns:
"Favor composition over inheritance"


I agree entirely there. :-)  However, the same question applies when 
using interfaces (which are common if you're doing composition).  See 
the language example I had earlier.  Where should the documentation of 
the hello() method go?  the Talk interface, the TalkInKlingon class, the 
TalkInSpanish class, all three...?


--Larry Garfield

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Method documentation

2010-05-27 Thread Richard Quadling
On 27 May 2010 18:10, Adam Richardson  wrote:
> On Thu, May 27, 2010 at 12:44 PM, la...@garfieldtech.com <
> la...@garfieldtech.com> wrote:
>
>> On 5/27/10 11:30 AM, Peter Lind wrote:
>>
>>  Sure, but @param, @access and possibly @return are but a part. I stand
> by my words: document the parent as a stub and provide actual
> documentation for the real implementations. Otherwise you're trying to
> be *clever* and will see the age-old result: you'll end up shooting
> yourself in the foot or worse places.
>
> Regards
> Peter
>

 ... What's "clever" about using OO inheritance the way it's designed to
 be
 used?  Are you actually suggesting that the solution is to insist on
 duplicating the docblock in every child class, which is a huge
 maintenance
 headache?

>>>
>>> If the implementations are the same in all child classes, then you're
>>> doing OO horribly wrong.
>>>
>>
>> Of course the implementations aren't the same.  That would be silly. But
>> the API is the same, by design.
>>
>>
>>  If they're *not* the same, then you'll merely
>>> be duplicating a part of the documentation (docblocks do *not* just
>>> consist of @param and @access) while writing the rest of the
>>> documentation to show what you're actually doing different in each
>>> method.
>>>
>>
>> I generally do not put a description of the entire internal algorithm into
>> the docblock, as that is not part of the API.  That's also by design.  Even
>> if there is implementation-specific stuff to add, the "short description
>> line", @params, @return, and lots of other things don't change, nor should
>> they.  So at best you're duplicating half the docblock each time.  Still a
>> high maintenance burden.
>>
>> --Larry Garfield
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
> Larry,
>
> I've thought about this very issue before (java developers sometimes lament
> this issue, too), and I error on the side of duplication if I'm using
> inheritance.
>
> However, I'd say I rarely use inheritance for anything in my development,
> and I'm much more likely to use composition.
>
> When a project evolves that's built almost entirely using design patterns
> focused on composition, I find that I very rarely have to duplicate any
> documentation, or rework documentation later on because a completely new
> component is being used.
>
> Outside of PHP (Scala, Objective C, F#, etc.), it seems like inheritance is
> advocated much less frequently, due to the power and simplicity of
> composition (e.g., change behavior at runtime, requires less knowledge of
> the parent classes.)
>
> Quoting the Head First book on design patterns:
> "Favor composition over inheritance"
>
> Now, there are situations where either inheritance is the most appropriate,
> and/or the architecture is not directly under your control.  And, as I said
> at the beginning, I tend to error on the side of duplication.  I just try to
> never put myself in that situation :)
>
> Adam
>
> --
> Nephtali:  PHP web framework that functions beautifully
> http://nephtaliproject.com
>

With the up-and-coming traits facility for PHP, it will be interesting
on how this gets resolved for documentation readers.


-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Convert UTF-8 to PHP defines

2010-05-27 Thread Bob McConnell
From: Ashley Sheridan

>On Thu, 2010-05-27 at 12:08 -0400, Adam Richardson wrote:
>
>> On Thu, May 27, 2010 at 9:45 AM, Guus Ellenkamp
>> wrote:
>> 
>> > Thanks, but are you sure of that? I did some research a while ago and found
>> > that officially PHP files should be ascii and not have any specific
>> > character encoding. I believe it will work anyhow (did not try this one),
>> > but would like to stick with the standards.
>> >
>> > "Ashley Sheridan"  wrote in message
>> > news:1274883714.2202.228.ca...@localhost...
>> > > On Wed, 2010-05-26 at 22:20 +0800, Guus Ellenkamp wrote:
>> > >
>> > >> We use PHP defines for defining text in different languages. As far as I
>> > >> know PHP files are supposed to be ASCII, not UTF-8 or something like
>> > >> that.
>> > >> What I want to make is a conversion program that would convert a given
>> > >> UTF-8
>> > >> file with the format
>> > >>
>> > >> definetext1=this is a text in random UTF-8, probably arabic or similar
>> > >> text
>> > >> definetext2=this is another text in random UTF-8, probably arabic or
>> > >> similar
>> > >> text
>> > >>
>> > >> into a file with the following defines
>> > >>
>> > >>
>> > define('definetext1',chr().chr().chr()...
> ).chr());
>> > >>
>> > define('definetext2,chr().chr().chr()...
> ).chr());
>> > >>
>> > >> Not sure if I'm using the correct chr/ord function, but I hope the above
>> > >> is
>> > >> clear enough to make clear what I'm looking for. Basically the output
>> > >> file
>> > >> should be ascii and not contain any utf-8.
>> > >>
>> > >> Any advise? The html_special_chars did not seem to work for Vietnamese
>> > >> text
>> > >> I tried to convert, so something seems to get wrong with just reading an
>> > >> array of strings and converting the strings and putting them in defines.
>> > >
>> > > PHP files can contain utf-8, and in-fact is the preference of most
>> > > developers I know of.
>> > >
>> >
>> Because the lower range of UTF-8 matches the ascii character set
>> (intentionally by design), you'll be able to use UTF-8 for PHP files without
>> problem (i.e., ascii 7-bit chars have same encoding in UTF-8.)
>> http://www.cl.cam.ac.uk/~mgk25/unicode.html
>> 
>> However, if you were to use any of the multibyte characters of UTF-8 in a
>> PHP file, you could run in to some trouble.  I use UTF-8 for most of my PHP
>> files, but I've been sticking to the ASCII subset exclusively.
>
> I don't use the higher range of characters often, but I do sometimes use
> them for things like the graphical glyphs (½✉✆, etc) I know I could do
> those with regular text and the Wingdings font, but that's not available
> on every computer, and breaks the semantic meaning behind the glyphs.

What higher range? ASCII only defined 128 values, the bottom 32 being control 
characters that don't print. Anything outside of that is not ASCII, but a 
proprietary extension. In particular, the glyphs usually associated with 0-32 
and 128-255 are IBM specific and not guaranteed to be present outside of their 
original video ROM. So only the first 128 characters map directly into UTF-8.

Bob McConnell

Ref: pp 25-29 The Programmer's PC Sourcebook, 1988, Thom Hogan, Microsoft Press


RE: [PHP] Convert UTF-8 to PHP defines

2010-05-27 Thread Ashley Sheridan
On Thu, 2010-05-27 at 14:06 -0400, Bob McConnell wrote:

> From: Ashley Sheridan
> 
> >On Thu, 2010-05-27 at 12:08 -0400, Adam Richardson wrote:
> >
> >> On Thu, May 27, 2010 at 9:45 AM, Guus Ellenkamp
> >> wrote:
> >> 
> >> > Thanks, but are you sure of that? I did some research a while ago and 
> >> > found
> >> > that officially PHP files should be ascii and not have any specific
> >> > character encoding. I believe it will work anyhow (did not try this one),
> >> > but would like to stick with the standards.
> >> >
> >> > "Ashley Sheridan"  wrote in message
> >> > news:1274883714.2202.228.ca...@localhost...
> >> > > On Wed, 2010-05-26 at 22:20 +0800, Guus Ellenkamp wrote:
> >> > >
> >> > >> We use PHP defines for defining text in different languages. As far 
> >> > >> as I
> >> > >> know PHP files are supposed to be ASCII, not UTF-8 or something like
> >> > >> that.
> >> > >> What I want to make is a conversion program that would convert a given
> >> > >> UTF-8
> >> > >> file with the format
> >> > >>
> >> > >> definetext1=this is a text in random UTF-8, probably arabic or similar
> >> > >> text
> >> > >> definetext2=this is another text in random UTF-8, probably arabic or
> >> > >> similar
> >> > >> text
> >> > >>
> >> > >> into a file with the following defines
> >> > >>
> >> > >>
> >> > define('definetext1',chr().chr().chr()...
> > ).chr());
> >> > >>
> >> > define('definetext2,chr().chr().chr()...
> > ).chr());
> >> > >>
> >> > >> Not sure if I'm using the correct chr/ord function, but I hope the 
> >> > >> above
> >> > >> is
> >> > >> clear enough to make clear what I'm looking for. Basically the output
> >> > >> file
> >> > >> should be ascii and not contain any utf-8.
> >> > >>
> >> > >> Any advise? The html_special_chars did not seem to work for Vietnamese
> >> > >> text
> >> > >> I tried to convert, so something seems to get wrong with just reading 
> >> > >> an
> >> > >> array of strings and converting the strings and putting them in 
> >> > >> defines.
> >> > >
> >> > > PHP files can contain utf-8, and in-fact is the preference of most
> >> > > developers I know of.
> >> > >
> >> >
> >> Because the lower range of UTF-8 matches the ascii character set
> >> (intentionally by design), you'll be able to use UTF-8 for PHP files 
> >> without
> >> problem (i.e., ascii 7-bit chars have same encoding in UTF-8.)
> >> http://www.cl.cam.ac.uk/~mgk25/unicode.html
> >> 
> >> However, if you were to use any of the multibyte characters of UTF-8 in a
> >> PHP file, you could run in to some trouble.  I use UTF-8 for most of my PHP
> >> files, but I've been sticking to the ASCII subset exclusively.
> >
> > I don't use the higher range of characters often, but I do sometimes use
> > them for things like the graphical glyphs (½✉✆, etc) I know I could do
> > those with regular text and the Wingdings font, but that's not available
> > on every computer, and breaks the semantic meaning behind the glyphs.
> 
> What higher range? ASCII only defined 128 values, the bottom 32 being control 
> characters that don't print. Anything outside of that is not ASCII, but a 
> proprietary extension. In particular, the glyphs usually associated with 0-32 
> and 128-255 are IBM specific and not guaranteed to be present outside of 
> their original video ROM. So only the first 128 characters map directly into 
> UTF-8.
> 
> Bob McConnell
> 
> Ref: pp 25-29 The Programmer's PC Sourcebook, 1988, Thom Hogan, Microsoft 
> Press


The higher range of utf8 characters that don't map to ascii values.

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




Re: [PHP] displaying database output in a table

2010-05-27 Thread Philip Thompson
On May 25, 2010, at 8:27 PM, David Mehler wrote:

> Hello,
> I'm trying to display mysql database output in a formatted table. My
> problem is i'm getting a blank screen with no errors. I've got
> debugging on, and have run the cli php on this file which produces no
> errors either, but neither does it give me any output.
> My eventual goal is to select the two nearest future events to the
> current date. Having done that I want to display the name, location,
> start date, start time, and a summary. Right now though I just want to
> put all information in the database in to a table.
> 
> Here's the code. Pointers welcome.
> Thanks.
> Dave.
> 
>  require_once($_SERVER['DOCUMENT_ROOT'] . "/dbconnect.php");

I ran into a similar issue yesterday. Tracked it down and figured out the 
"required" file did not exist. It didn't show up in my dev environment b/c I 
had the file. When we pushed it to QA, the file had not been uploaded. The 
require_once() stops execution if the file isn't found. Try changing it to 
include_once() and see if you can _any_ output.

Hope this helps.
~Philip


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] displaying database output in a table

2010-05-27 Thread Ashley Sheridan
On Thu, 2010-05-27 at 13:16 -0500, Philip Thompson wrote:

> On May 25, 2010, at 8:27 PM, David Mehler wrote:
> 
> > Hello,
> > I'm trying to display mysql database output in a formatted table. My
> > problem is i'm getting a blank screen with no errors. I've got
> > debugging on, and have run the cli php on this file which produces no
> > errors either, but neither does it give me any output.
> > My eventual goal is to select the two nearest future events to the
> > current date. Having done that I want to display the name, location,
> > start date, start time, and a summary. Right now though I just want to
> > put all information in the database in to a table.
> > 
> > Here's the code. Pointers welcome.
> > Thanks.
> > Dave.
> > 
> >  > require_once($_SERVER['DOCUMENT_ROOT'] . "/dbconnect.php");
> 
> I ran into a similar issue yesterday. Tracked it down and figured out the 
> "required" file did not exist. It didn't show up in my dev environment b/c I 
> had the file. When we pushed it to QA, the file had not been uploaded. The 
> require_once() stops execution if the file isn't found. Try changing it to 
> include_once() and see if you can _any_ output.
> 
> Hope this helps.
> ~Philip
> 
> 


I'd tend to try and keep scripts as self contained as possible, so I can
get away with using relative paths which don't rely on variables in
$_SERVER. Also, I've been led to believe that $_SERVER variables are a
point of entry for injection attacks, so shouldn't be relied upon,
although I'm sure that's not the case for everything in the $_SERVER
array.

I think this is the reason why a lot of systems and frameworks have a
config file which require the paths to be set up completely, without
relying on these special global arrays.

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




RE: [PHP] displaying database output in a table

2010-05-27 Thread Bob McConnell
From: Philip Thompson

> On May 25, 2010, at 8:27 PM, David Mehler wrote:
> 
>> Hello,
>> I'm trying to display mysql database output in a formatted table. My
>> problem is i'm getting a blank screen with no errors. I've got
>> debugging on, and have run the cli php on this file which produces no
>> errors either, but neither does it give me any output.
>> My eventual goal is to select the two nearest future events to the
>> current date. Having done that I want to display the name, location,
>> start date, start time, and a summary. Right now though I just want
to
>> put all information in the database in to a table.
>> 
>> Here's the code. Pointers welcome.
>> Thanks.
>> Dave.
>> 
>> > require_once($_SERVER['DOCUMENT_ROOT'] . "/dbconnect.php");
> 
> I ran into a similar issue yesterday. Tracked it down and figured out
> the "required" file did not exist. It didn't show up in my dev
> environment b/c I had the file. When we pushed it to QA, the file had
> not been uploaded. The require_once() stops execution if the file
isn't
> found. Try changing it to include_once() and see if you can _any_
output.

We struggled with this as well. require terminates the process without
any indication of why it stopped. No error, no exception, not even a
whimper. Recording a basic "file not found" message in the error log
would be a major improvement.

Bob McConnell

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Method documentation

2010-05-27 Thread Adam Richardson
On Thu, May 27, 2010 at 1:14 PM, la...@garfieldtech.com <
la...@garfieldtech.com> wrote:

> On 5/27/10 12:10 PM, Adam Richardson wrote:
>
>  Larry,
>>
>> I've thought about this very issue before (java developers sometimes
>> lament
>> this issue, too), and I error on the side of duplication if I'm using
>> inheritance.
>>
>> However, I'd say I rarely use inheritance for anything in my development,
>> and I'm much more likely to use composition.
>>
>> When a project evolves that's built almost entirely using design patterns
>> focused on composition, I find that I very rarely have to duplicate any
>> documentation, or rework documentation later on because a completely new
>> component is being used.
>>
>> Outside of PHP (Scala, Objective C, F#, etc.), it seems like inheritance
>> is
>> advocated much less frequently, due to the power and simplicity of
>> composition (e.g., change behavior at runtime, requires less knowledge of
>> the parent classes.)
>>
>> Quoting the Head First book on design patterns:
>> "Favor composition over inheritance"
>>
>
> I agree entirely there. :-)  However, the same question applies when using
> interfaces (which are common if you're doing composition).  See the language
> example I had earlier.  Where should the documentation of the hello() method
> go?  the Talk interface, the TalkInKlingon class, the TalkInSpanish class,
> all three...?
>
>
> --Larry Garfield
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
I probably would take a different approach.  I'd make a Talk Object, which
would serve as the primary front end for most developers using the API, and
use a translator object to handle the implementation.

class Talk{
 private $translator;
 /**
  * Creates Talk object and sets default translator to English.
  */
 function __construct() {
  $this->translator = new EnglishTranslator();
 }
 /**
  * Sets translator to new object implementing ITranslator interface.
  */
 public function setTranslator(ITranslator $translator) {
  $this->translator = $translator;
 }
 /**
  * Prints a message in the language translated by the current translator
object.
  *
  * @param $message
  *   A key indicating the message to pull from the DB
  *   and print.
  * @return boolean
  *   TRUE if it worked, FALSE otherwise.
  */
 public function say($message) {
  echo $this->translator->say($message);
  return true;
 }
}

$talker = new Talk();
$talker->say($message = "Hello");
$talker->setTranslator(new SpanishTranslator());
$talker->say($message = "Hello");
$talker->setTranslator(new KlingonTranslator());
$talker->say($message = "Hello");

// Hopefully outputs "Hello", "Hola", and "nuqneH"

Now, you still would have to document all of the classes that implement the
say() method, but these would all differ in ways that make this much less
redundant than the other scheme (at least I think of them semantically in
this way.)  The Talk object is essentially the proxy we use to many possible
translators.  So, the code completion would work, along with the docblock
info.

This scheme could be extended to utilize Inversion of Control (IoC), making
changes to translators in the future (maybe there's a new dialect of Klingon
that should be utilized for visitors from the urban regions of Kronos) a
breeze.

Just some quick thoughts (sorry if there are PHP errors, I just quick typed
into my email and I've got to get back to work.)  And, to stress this point,
this is just how I would do this (at least after a cursory look at your
example.)  This isn't THE RIGHT way (and some might say it isn't even A
right way.)

I wish you well as you try to resolve this going forward on your project :)

Adam

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


Re: [PHP] Method documentation

2010-05-27 Thread Adam Richardson
>
>
> > Larry,
> >
> > I've thought about this very issue before (java developers sometimes
> lament
> > this issue, too), and I error on the side of duplication if I'm using
> > inheritance.
> >
> > However, I'd say I rarely use inheritance for anything in my development,
> > and I'm much more likely to use composition.
> >
> > When a project evolves that's built almost entirely using design patterns
> > focused on composition, I find that I very rarely have to duplicate any
> > documentation, or rework documentation later on because a completely new
> > component is being used.
> >
> > Outside of PHP (Scala, Objective C, F#, etc.), it seems like inheritance
> is
> > advocated much less frequently, due to the power and simplicity of
> > composition (e.g., change behavior at runtime, requires less knowledge of
> > the parent classes.)
> >
> > Quoting the Head First book on design patterns:
> > "Favor composition over inheritance"
> >
> > Now, there are situations where either inheritance is the most
> appropriate,
> > and/or the architecture is not directly under your control.  And, as I
> said
> > at the beginning, I tend to error on the side of duplication.  I just try
> to
> > never put myself in that situation :)
> >
> > Adam
> >
> > --
> > Nephtali:  PHP web framework that functions beautifully
> > http://nephtaliproject.com
> >
>
> With the up-and-coming traits facility for PHP, it will be interesting
> on how this gets resolved for documentation readers.
>
>
Indeed, I'm excited for the new capabilities, but they won't come easily in
terms of the development ecosystem.

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


RE: [PHP] Convert UTF-8 to PHP defines

2010-05-27 Thread tedd

At 7:11 PM +0100 5/27/10, Ashley Sheridan wrote:

On Thu, 2010-05-27 at 14:06 -0400, Bob McConnell wrote:
 > From: Ashley Sheridan
 > > I don't use the higher range of characters often, but I do sometimes use

 > them for things like the graphical glyphs (1Ž2)&, etc) I know I could do
 > those with regular text and the Wingdings font, but that's not available
 > on every computer, and breaks the semantic meaning behind the glyphs.

 What higher range? ASCII only defined 128 
values, the bottom 32 being control characters 
that don't print. Anything outside of that is 
not ASCII, but a proprietary extension. In 
particular, the glyphs usually associated with 
0-32 and 128-255 are IBM specific and not 
guaranteed to be present outside of their 
original video ROM. So only the first 128 
characters map directly into UTF-8.


 Bob McConnell

 Ref: pp 25-29 The Programmer's PC Sourcebook, 
1988, Thom Hogan, Microsoft Press



The higher range of utf8 characters that don't map to ascii values.

Thanks,
Ash


Bob:

I understood what Ash was referring re his 
"higher range" statement, but his second 
statement was somewhat confusing.


ASCII is defined as characters having a value of 
0-127 DEC (00-7F HEX). The "higher range" of 
128-255 DEC (80-FF HEX) have been loosely 
characterized as "extended ASCII" but have not 
been officially declared such. Both M$ and Apple 
have their own characters appearing the range and 
have used different character for different 
things -- thus problems arose is using either. I 
do not know if the problem was ever resolved. 
It's probably best to never use such characters.


The Unicode database uses the same lower 
character values (i.e., "code points") as does 
ASCII, namely 0-127, and thus UFT-8 (8-bit 
variable width encoding) is really a super-set 
which includes the sub-set of ASCII.


The "Wingdings" font that Ash refers to is the 
really the "Dingbat" char set in Unicode, as 
shown here:


http://www.unicode.org/charts/PDF/U2700.pdf

These are real characters that can be used for 
all sorts of things including url's, for example:


http://xn--gci.com

Please forgive the PUNYCODE url, but IE does not 
recognize "other than ASCII" characters in url's, 
whereas Safari will show the url correctly. 
Clearly, Safari has the upper hand in resolving 
"other than English" issues -- perhaps that's why 
their overseas profits last year exceeded their 
domestic -- but I digress.


The use of UFT-8 encoding in everything (web and 
php) should present much less problems globally 
than it is trying to fight it.


Here's some references that may help:

[1] 
[2] 
[3] 
[4] 
[5] 
[6] 

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] Convert UTF-8 to PHP defines

2010-05-27 Thread Bob McConnell
From: tedd

> The Unicode database uses the same lower 
> character values (i.e., "code points") as does 
> ASCII, namely 0-127, and thus UFT-8 (8-bit 
> variable width encoding) is really a super-set 
> which includes the sub-set of ASCII.
> 
> The "Wingdings" font that Ash refers to is the 
> really the "Dingbat" char set in Unicode, as 
> shown here:
> 
> The use of UFT-8 encoding in everything (web and 
> php) should present much less problems globally 
> than it is trying to fight it.

Thanks tedd,

The real question is whether unicode is even relevant now that the UTF
series is available. I see no reason to have to deal with two competing
"specifications", when one of them is more than adequate for the job and
the other is not even finished yet. That's like the old days when a few
users demanded we support both ASCII and EBCDIC. That didn't get very
far either.

Bob McConnell

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Convert UTF-8 to PHP defines

2010-05-27 Thread Ashley Sheridan
On Thu, 2010-05-27 at 15:28 -0400, Bob McConnell wrote:

> From: tedd
> 
> > The Unicode database uses the same lower 
> > character values (i.e., "code points") as does 
> > ASCII, namely 0-127, and thus UFT-8 (8-bit 
> > variable width encoding) is really a super-set 
> > which includes the sub-set of ASCII.
> > 
> > The "Wingdings" font that Ash refers to is the 
> > really the "Dingbat" char set in Unicode, as 
> > shown here:
> > 
> > The use of UFT-8 encoding in everything (web and 
> > php) should present much less problems globally 
> > than it is trying to fight it.
> 
> Thanks tedd,
> 
> The real question is whether unicode is even relevant now that the UTF
> series is available. I see no reason to have to deal with two competing
> "specifications", when one of them is more than adequate for the job and
> the other is not even finished yet. That's like the old days when a few
> users demanded we support both ASCII and EBCDIC. That didn't get very
> far either.
> 
> Bob McConnell
> 


Bob, UTF is unicode (Unicode Transformation Format)

Interesting enough to note, and not sure if Tedd knows this or not (he
probably does!) but Chrome has a nice feature for those punycode URLs;
it suggests the actual real URL instead once you type the domain in. Not
sure about Safari right now, couldn't be bothered to fire up a VM just
to check. I would assume Firefox handles these URLs well enough too.

Tedd, does that URL actually go anywhere, as I got nothing when I tried
visiting it, both the actual URL and the punycode version.

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




Re: Re[2]: [PHP] One more time about regexes

2010-05-27 Thread Adam Richardson
On Thu, May 27, 2010 at 4:13 AM, Andre Polykanine  wrote:

> Hello Adam,
>
> You did understand me exactly and perfectly).
> Ordering arrays is a good idea but I don't know how to do that
> exactly.
> For instance, there's a cypher called Polybius square. You write in
> the alphabet in a grid like this:
> 1 a b c d e
> 2 f g h i j
> 3 k l m n o
> 4 p q r s t
> 5 u v w x y
> 6 z
>
> There is a way where i/j are equal to make a 5 by 5 square but for me
> it's equal since I'm working with a 33-letter Russian alphabet, so no
> way to make it a perfect square.
> Anyway, a letter has two coordinates and is represented by a two-digit
> number. For example, E is 15, K is 21, Z is 61 and so on.
> So we have a word, say, PHP. It will look like this: 412341.
> What does preg_replace do? Exactly, it's searching 41, then 12, then
> 23, and so on.
> I tried to make a loop:
> $length=mb_strlen($str);
> for ($i=0; $i<$length; $i+=2) {
> $pair=mb_substr($str, $i, 2);
> $pair=preg_replace($numbers, $letters, $str);
> }
>
> It already smells something not good, but anyway.
> If I do that, I have one more problem: say, we have a phrase "PHP is
> the best". So we crypt it and get:
> 412341 2444 452315 12154445
> Then the parser begins: "41=>p, 23=>h, 41=>p, (attention!) \s2=>"
> I marked a whitespace as \s so you see what happens.
> I might split the string by spaces but I can't imagine what a user
> inputs: it might be a dash, for example...
> Sorry for such a long message but I'm really annoyed with this
> preg_replace's behavior. And it's not the only one task to
> accomplish...
> Thanks a lot!
>
> --
> With best regards from Ukraine,
> Andre
> Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @
> jabber.org
> Yahoo! messenger: andre.polykanine; ICQ: 191749952
> Twitter: m_elensule
>
> - Original message -
> From: Adam Richardson 
> To: php-general@lists.php.net 
> Date: Thursday, May 27, 2010, 7:56:28 AM
> Subject: [PHP] One more time about regexes
>
> On Wed, May 26, 2010 at 11:10 PM, Nilesh Govindarajan  >wrote:
>
> > -- Forwarded message --
> > From: Nilesh Govindarajan 
> > Date: Thu, May 27, 2010 at 8:40 AM
> > Subject: Re: [PHP] One more time about regexes
> > To: Andre Polykanine 
> >
> >
> > On Thu, May 27, 2010 at 3:33 AM, Andre Polykanine 
> wrote:
> > > Hello everyone,
> > >
> > > Sorry, but I'm asking one more time (since it's really annoying me and
> > > I need to apply some really dirty hacks):
> > > Is there a way making preg_replace() pass through the regex one single
> > > time searching from left to right and not to erase what it has already
> > > done?
> > > I can give you a real task I'm accomplishing but the tasks requiring
> > > that tend to multiply...
> > > Thanks a lot!
> > >
> > > --
> > > With best regards from Ukraine,
> > > Andre
> > > Http://oire.org/ - The Fantasy blogs of Oire
> > > Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon
> @
> > jabber.org
> > > Yahoo! messenger: andre.polykanine; ICQ: 191749952
> > > Twitter: http://twitter.com/m_elensule
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> >
> >
> > If you don't want to replace the stuff it has searched then use
> preg_match
> > !
> >
> > --
> > Nilesh Govindarajan
> > Facebook: nilesh.gr
> > Twitter: nileshgr
> > Website: www.itech7.com
> >
> >
> >
> > --
> > Nilesh Govindarajan
> > Facebook: nilesh.gr
> > Twitter: nileshgr
> > Website: www.itech7.com
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> If I'm understanding correctly, Andre, you want to perform a replace
> operation, but you're observing that there's an element of recursion
> happening (e.g., you replace one item with its replacement, and then the
> new
> replacement is also replaced.)
>
> To my knowledge, this won't happen with a standard preg_replace():
>
> $string = 'Bil & Tom & Phil';
> $pattern = '/&/';
> $replacement = '&';
> // outputs Bil & Tom & Phil
> echo preg_replace($pattern, $replacement, $string);
>
> However, if you're using arrays to pass in the patterns and replacements,
> then one array item could later be replaced by another (see comment and
> example on this page by info at gratisrijden dot nl):
> http://php.net/manual/en/function.preg-replace.php
>
> If that's the case, you have to carefully structure the order of the array
> items so-as to preclude one replacement having the opportunity to override
> a
> subsequent replacement.
>
> Sorry if I misunderstood.  You might want to create a simple example of
> code
> showing what you're working through.
>
> Adam
>
>
> --
> Nephtali:  PHP web framework that functions beautifully
> http://nephtaliproject.com
>
>
Andre,

I'd try something like this:

square_values = array();
$chars = str_split($values_string);

for ($i = 1; $i < ($square_dimension + 

Re: [PHP] Method documentation

2010-05-27 Thread Waynn Lue
I've seen @inheritDoc used in Java before, though I'm not sure about
the php support.

Waynn

On 5/27/10, Adam Richardson  wrote:
>>
>>
>> > Larry,
>> >
>> > I've thought about this very issue before (java developers sometimes
>> lament
>> > this issue, too), and I error on the side of duplication if I'm using
>> > inheritance.
>> >
>> > However, I'd say I rarely use inheritance for anything in my
>> > development,
>> > and I'm much more likely to use composition.
>> >
>> > When a project evolves that's built almost entirely using design
>> > patterns
>> > focused on composition, I find that I very rarely have to duplicate any
>> > documentation, or rework documentation later on because a completely new
>> > component is being used.
>> >
>> > Outside of PHP (Scala, Objective C, F#, etc.), it seems like inheritance
>> is
>> > advocated much less frequently, due to the power and simplicity of
>> > composition (e.g., change behavior at runtime, requires less knowledge
>> > of
>> > the parent classes.)
>> >
>> > Quoting the Head First book on design patterns:
>> > "Favor composition over inheritance"
>> >
>> > Now, there are situations where either inheritance is the most
>> appropriate,
>> > and/or the architecture is not directly under your control.  And, as I
>> said
>> > at the beginning, I tend to error on the side of duplication.  I just
>> > try
>> to
>> > never put myself in that situation :)
>> >
>> > Adam
>> >
>> > --
>> > Nephtali:  PHP web framework that functions beautifully
>> > http://nephtaliproject.com
>> >
>>
>> With the up-and-coming traits facility for PHP, it will be interesting
>> on how this gets resolved for documentation readers.
>>
>>
> Indeed, I'm excited for the new capabilities, but they won't come easily in
> terms of the development ecosystem.
>
> --
> Nephtali:  PHP web framework that functions beautifully
> http://nephtaliproject.com
>

-- 
Sent from my mobile device

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Method documentation

2010-05-27 Thread Adam Richardson
On Thu, May 27, 2010 at 3:59 PM, Waynn Lue  wrote:

> I've seen @inheritDoc used in Java before, though I'm not sure about
> the php support.
>
> Waynn
>
> On 5/27/10, Adam Richardson  wrote:
> >>
> >>
> >> > Larry,
> >> >
> >> > I've thought about this very issue before (java developers sometimes
> >> lament
> >> > this issue, too), and I error on the side of duplication if I'm using
> >> > inheritance.
> >> >
> >> > However, I'd say I rarely use inheritance for anything in my
> >> > development,
> >> > and I'm much more likely to use composition.
> >> >
> >> > When a project evolves that's built almost entirely using design
> >> > patterns
> >> > focused on composition, I find that I very rarely have to duplicate
> any
> >> > documentation, or rework documentation later on because a completely
> new
> >> > component is being used.
> >> >
> >> > Outside of PHP (Scala, Objective C, F#, etc.), it seems like
> inheritance
> >> is
> >> > advocated much less frequently, due to the power and simplicity of
> >> > composition (e.g., change behavior at runtime, requires less knowledge
> >> > of
> >> > the parent classes.)
> >> >
> >> > Quoting the Head First book on design patterns:
> >> > "Favor composition over inheritance"
> >> >
> >> > Now, there are situations where either inheritance is the most
> >> appropriate,
> >> > and/or the architecture is not directly under your control.  And, as I
> >> said
> >> > at the beginning, I tend to error on the side of duplication.  I just
> >> > try
> >> to
> >> > never put myself in that situation :)
> >> >
> >> > Adam
> >> >
> >> > --
> >> > Nephtali:  PHP web framework that functions beautifully
> >> > http://nephtaliproject.com
> >> >
> >>
> >> With the up-and-coming traits facility for PHP, it will be interesting
> >> on how this gets resolved for documentation readers.
> >>
> >>
> > Indeed, I'm excited for the new capabilities, but they won't come easily
> in
> > terms of the development ecosystem.
> >
> > --
> > Nephtali:  PHP web framework that functions beautifully
> > http://nephtaliproject.com
> >
>
> --
> Sent from my mobile device
>

You're absolutely right, Waynn,

Phpdocumentor has this, too:
http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_tags.inlineinheritdoc.pkg.html

However, Netbeans (and I'm assuming other PHP IDE's, but I'm only using
Netbeans) doesn't parse the inheritdoc element so its info is available with
code-completion.  I think Larry was trying to find something that would work
for both generated documentation AND IDE auto-complete capabilities.

Adam

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


[PHP] still having trouble with time-stamp subtraction two mysql fields

2010-05-27 Thread Bruce Gilbert
Hi there,

I am still attempting to get a display of the result of my two
timestamp fields subtracted from one another in minutes and hours if
needed. This is for a form and the timestamps are recorded when a user
logs in [login_timestamp] and when the form is
submitted[submit_timestamp]. The display still doesn't appear to be
accurate and for some reason the results are displayed three times for
each record underneath the results for one person. So it looks
something like.

Tom Thumb
Answer 1
Answer 2
Answer 3 etc.
[time 1]
[time 2]
[time 3]

Sally Smith
Answer 1
Answer 2
Answer 3 etc.
[time 1]
[time 2]
[time 3]

Bob Jones
Answer 1
Answer 2
Answer 3
[time 1]
[time 2]
[time 3]

time1,2,3 being for Tom Thumb, Sally Smith and Bob Jones respectively.

My entire code for the form looks like this.



Exam Results



exam results

Candidate Name

{$row['name']}";
echo "Section 1";

   for ($i =1;$i<9;++$i) {
echo "{$row['Answer'.$i]}";
  }
echo "Section 2";

echo "{$row['Answer10']}";
echo "Section 3";

echo "{$row['Answer11']}";
echo "Section 4";

echo "{$row['Answer12']}";



$sql_timestamp = "SELECT
TIMESTAMPDIFF(SECOND,submit_timestamp,login_timestamp) as cTime FROM
Responses LEFT JOIN Candidates USING (user_id)";

$result_timestamp = mysql_query($sql_timestamp);
if (!$result_timestamp) {
echo "Could not successfully run query ($sql_timestamp) from DB: "
. mysql_error();
exit;
}
while($row = mysql_fetch_assoc($result_timestamp)){
  $formatted_completion_time = formatTime($row['cTime']);
  echo "Completion Time:\n";
  echo $formatted_completion_time;
  echo "";
}

}
mysql_free_result($result);



?>





and my function code for the subtracting of the two fields is here:



any assistance that can be provided is greatly appreciated.

-- 
::Bruce::

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] displaying database output in a table

2010-05-27 Thread David Mehler
Hello Everyone,
Thanks for all your suggestions. Unfortunately, I've replaced
require_once with include_once and require with include in all the
documents, I'm still not having any luck.
Thanks.
Dave.


On 5/27/10, Bob McConnell  wrote:
> From: Philip Thompson
>
>> On May 25, 2010, at 8:27 PM, David Mehler wrote:
>>
>>> Hello,
>>> I'm trying to display mysql database output in a formatted table. My
>>> problem is i'm getting a blank screen with no errors. I've got
>>> debugging on, and have run the cli php on this file which produces no
>>> errors either, but neither does it give me any output.
>>> My eventual goal is to select the two nearest future events to the
>>> current date. Having done that I want to display the name, location,
>>> start date, start time, and a summary. Right now though I just want
> to
>>> put all information in the database in to a table.
>>>
>>> Here's the code. Pointers welcome.
>>> Thanks.
>>> Dave.
>>>
>>> >> require_once($_SERVER['DOCUMENT_ROOT'] . "/dbconnect.php");
>>
>> I ran into a similar issue yesterday. Tracked it down and figured out
>> the "required" file did not exist. It didn't show up in my dev
>> environment b/c I had the file. When we pushed it to QA, the file had
>> not been uploaded. The require_once() stops execution if the file
> isn't
>> found. Try changing it to include_once() and see if you can _any_
> output.
>
> We struggled with this as well. require terminates the process without
> any indication of why it stopped. No error, no exception, not even a
> whimper. Recording a basic "file not found" message in the error log
> would be a major improvement.
>
> Bob McConnell
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] displaying database output in a table

2010-05-27 Thread Adam Richardson
On Thu, May 27, 2010 at 5:47 PM, David Mehler  wrote:

> Hello Everyone,
> Thanks for all your suggestions. Unfortunately, I've replaced
> require_once with include_once and require with include in all the
> documents, I'm still not having any luck.
> Thanks.
> Dave.
>
>
> On 5/27/10, Bob McConnell  wrote:
> > From: Philip Thompson
> >
> >> On May 25, 2010, at 8:27 PM, David Mehler wrote:
> >>
> >>> Hello,
> >>> I'm trying to display mysql database output in a formatted table. My
> >>> problem is i'm getting a blank screen with no errors. I've got
> >>> debugging on, and have run the cli php on this file which produces no
> >>> errors either, but neither does it give me any output.
> >>> My eventual goal is to select the two nearest future events to the
> >>> current date. Having done that I want to display the name, location,
> >>> start date, start time, and a summary. Right now though I just want
> > to
> >>> put all information in the database in to a table.
> >>>
> >>> Here's the code. Pointers welcome.
> >>> Thanks.
> >>> Dave.
> >>>
> >>>  >>> require_once($_SERVER['DOCUMENT_ROOT'] . "/dbconnect.php");
> >>
> >> I ran into a similar issue yesterday. Tracked it down and figured out
> >> the "required" file did not exist. It didn't show up in my dev
> >> environment b/c I had the file. When we pushed it to QA, the file had
> >> not been uploaded. The require_once() stops execution if the file
> > isn't
> >> found. Try changing it to include_once() and see if you can _any_
> > output.
> >
> > We struggled with this as well. require terminates the process without
> > any indication of why it stopped. No error, no exception, not even a
> > whimper. Recording a basic "file not found" message in the error log
> > would be a major improvement.
> >
> > Bob McConnell
> >
> > --
> > 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
>
>
Can you show us what the current code looks like?

Adam

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


Re: [PHP] Method documentation

2010-05-27 Thread la...@garfieldtech.com

On 5/27/10 3:15 PM, Adam Richardson wrote:

On Thu, May 27, 2010 at 3:59 PM, Waynn Lue  wrote:


I've seen @inheritDoc used in Java before, though I'm not sure about
the php support.

Waynn




You're absolutely right, Waynn,

Phpdocumentor has this, too:
http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_tags.inlineinheritdoc.pkg.html

However, Netbeans (and I'm assuming other PHP IDE's, but I'm only using
Netbeans) doesn't parse the inheritdoc element so its info is available with
code-completion.  I think Larry was trying to find something that would work
for both generated documentation AND IDE auto-complete capabilities.

Adam


Correct.  @inheritDoc sounds promising.  However, of the three possible 
consumers (humans reading the code, IDEs reading the code, and 
documentation generators reading the code) the documentation generator 
is lowest priority; I figure whatever we end up doing we can write the 
script to handle it.


I'm getting the impression that we either say FU to people reading the 
code or FU to people using IDEs. :-(  Either that or duplicate at least 
large swaths of the documentation (the shortdesc, @params, and @return 
at least).


--Larry Garfield

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] JSON RPC with SSL and .pem certificates?

2010-05-27 Thread Daevid Vincent
Anyone have a good example or routine or library or something that will use
JSON-RPC client and SSL .pem certs? All the code I've found out there is
pretty dated or unkept or lacks one or more of those requirements.

http://jsonrpcphp.org/ is about as close as I could find, but it doesn't
use SSL and hasn't been touched since 2007.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms

2010-05-27 Thread Alice Wei

  
> Date: Thu, 27 May 2010 12:23:46 -0400
> To: aj...@alumni.iu.edu; php-general@lists.php.net
> From: tedd.sperl...@gmail.com
> Subject: RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms
> 
> At 3:50 PM -0400 5/26/10, Alice Wei wrote:
> >
> > My bad, I cannot imagine I sent that stuff. To answer your 
> >question, here it is,
> >
> > 
> > Select the type of your starting point of interest:
> >  >maxlength="50"/>
> >
> > 
> > 
> >
> >
> >This is what is working now if I do it this way, but again, then I 
> >got to make sure everything is "typed up properly" before the form 
> >is submitted. Does this answer your questions by any chance?
> >
> >
> >Alice
> >
> 
> Alice:
> 
> Okay, not bad -- here's my addition:
> 
> http://www.webbytedd.com//alice/
> 
> Please review the code. I removed the maxlength because that's 
> something you should do server-side anyway. Never trust anything 
> coming from the client-side.
> 
> Also note that closing the tags, such as  is optional -- IF -- 
> you're not planning on using XML. Otherwise they will generate a W3C 
> short-tags warning. However, that's not a fatal error.
> 
> Also note the Submit button statement has three attributes. Type 
> states the type of input statement, value is what the button displays 
> to the user (i.e., Submit") and name is the name of the variable that 
> you can access via a POST/GET.
> 
> Also note how the form collects the "start" value from a POST and 
> then repopulates the form after it has the data. This important to 
> understand. Clicking the "Submit" button sends the form's data to the 
> server which then sends it back to the browser via a refreshed form.
> 
> Also note the ternary operator I used, namely:
> 
> $start = isset($_POST['start']) ? $_POST['start'] : null;
> 
> The first time the page is viewed, POST is sampled for content. If 
> there is no content, then checking for content will generate an error 
> unless we first check to see if it has content, hence the isset(). If 
> it doesn't have content, then the statement assigns NULL to $start. 
> If it does have content, then it will assign that value to $start, 
> understand?
> 
> Now, what's next? What other data do you want to collect? You 
> mentioned a select control that derived its data from a database. But 
> before we go to that, show me a "select" control working in a form 
> with embedded values -- in other words, just a simple select control. 
> Please add it to the form we have.
> 
> Cheers,
> 
> 
> tedd
> 
 
I am not sure how to add to the page you have set up, but here is the code with 
ther portion you have set up:
 



  
Select the type of your starting point of interest:

Which Semster is this: 
Fall
Spring
Summer


  


 Note, what I provided here does not include anything on the ajax. 

 

Hope this answers your question. 

 

Alice

> -- 
> ---
> http://sperling.com http://ancientstones.com http://earthstones.com


  
_
The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with 
Hotmail. 
http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5

Re: [PHP] displaying database output in a table

2010-05-27 Thread Ashley Sheridan
On Thu, 2010-05-27 at 17:59 -0400, Adam Richardson wrote:

> On Thu, May 27, 2010 at 5:47 PM, David Mehler  wrote:
> 
> > Hello Everyone,
> > Thanks for all your suggestions. Unfortunately, I've replaced
> > require_once with include_once and require with include in all the
> > documents, I'm still not having any luck.
> > Thanks.
> > Dave.
> >
> >
> > On 5/27/10, Bob McConnell  wrote:
> > > From: Philip Thompson
> > >
> > >> On May 25, 2010, at 8:27 PM, David Mehler wrote:
> > >>
> > >>> Hello,
> > >>> I'm trying to display mysql database output in a formatted table. My
> > >>> problem is i'm getting a blank screen with no errors. I've got
> > >>> debugging on, and have run the cli php on this file which produces no
> > >>> errors either, but neither does it give me any output.
> > >>> My eventual goal is to select the two nearest future events to the
> > >>> current date. Having done that I want to display the name, location,
> > >>> start date, start time, and a summary. Right now though I just want
> > > to
> > >>> put all information in the database in to a table.
> > >>>
> > >>> Here's the code. Pointers welcome.
> > >>> Thanks.
> > >>> Dave.
> > >>>
> > >>>  > >>> require_once($_SERVER['DOCUMENT_ROOT'] . "/dbconnect.php");
> > >>
> > >> I ran into a similar issue yesterday. Tracked it down and figured out
> > >> the "required" file did not exist. It didn't show up in my dev
> > >> environment b/c I had the file. When we pushed it to QA, the file had
> > >> not been uploaded. The require_once() stops execution if the file
> > > isn't
> > >> found. Try changing it to include_once() and see if you can _any_
> > > output.
> > >
> > > We struggled with this as well. require terminates the process without
> > > any indication of why it stopped. No error, no exception, not even a
> > > whimper. Recording a basic "file not found" message in the error log
> > > would be a major improvement.
> > >
> > > Bob McConnell
> > >
> > > --
> > > 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
> >
> >
> Can you show us what the current code looks like?
> 
> Adam
> 


What do you get if you just echo out $_SERVER['DOCUMENT_ROOT']?

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




Re: [PHP] Convert UTF-8 to PHP defines

2010-05-27 Thread Guus Ellenkamp
And I need(ed) this stuff especially for non-ASCII characters like Chinese, 
Arabic and stuff :)

"Ashley Sheridan"  wrote in message 
news:1274976794.2202.274.ca...@localhost...
On Thu, 2010-05-27 at 12:08 -0400, Adam Richardson wrote:

> On Thu, May 27, 2010 at 9:45 AM, Guus Ellenkamp
> wrote:
>
> > Thanks, but are you sure of that? I did some research a while ago and 
> > found
> > that officially PHP files should be ascii and not have any specific
> > character encoding. I believe it will work anyhow (did not try this 
> > one),
> > but would like to stick with the standards.
> >
> > "Ashley Sheridan"  wrote in message
> > news:1274883714.2202.228.ca...@localhost...
> > > On Wed, 2010-05-26 at 22:20 +0800, Guus Ellenkamp wrote:
> > >
> > >> We use PHP defines for defining text in different languages. As far 
> > >> as I
> > >> know PHP files are supposed to be ASCII, not UTF-8 or something like
> > >> that.
> > >> What I want to make is a conversion program that would convert a 
> > >> given
> > >> UTF-8
> > >> file with the format
> > >>
> > >> definetext1=this is a text in random UTF-8, probably arabic or 
> > >> similar
> > >> text
> > >> definetext2=this is another text in random UTF-8, probably arabic or
> > >> similar
> > >> text
> > >>
> > >> into a file with the following defines
> > >>
> > >>
> > define('definetext1',chr().chr().chr()...).chr());
> > >>
> > define('definetext2,chr().chr().chr()...).chr());
> > >>
> > >> Not sure if I'm using the correct chr/ord function, but I hope the 
> > >> above
> > >> is
> > >> clear enough to make clear what I'm looking for. Basically the output
> > >> file
> > >> should be ascii and not contain any utf-8.
> > >>
> > >> Any advise? The html_special_chars did not seem to work for 
> > >> Vietnamese
> > >> text
> > >> I tried to convert, so something seems to get wrong with just reading 
> > >> an
> > >> array of strings and converting the strings and putting them in 
> > >> defines.
> > >>
> > >>
> > >>
> > >
> > >
> > > PHP files can contain utf-8, and in-fact is the preference of most
> > > developers I know of.
> > >
> > > Thanks,
> > > Ash
> > > http://www.ashleysheridan.co.uk
> > >
> > >
> > >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> Because the lower range of UTF-8 matches the ascii character set
> (intentionally by design), you'll be able to use UTF-8 for PHP files 
> without
> problem (i.e., ascii 7-bit chars have same encoding in UTF-8.)
> http://www.cl.cam.ac.uk/~mgk25/unicode.html
>
> However, if you were to use any of the multibyte characters of UTF-8 in a
> PHP file, you could run in to some trouble.  I use UTF-8 for most of my 
> PHP
> files, but I've been sticking to the ASCII subset exclusively.
>
> Adam
>


I don't use the higher range of characters often, but I do sometimes use
them for things like the graphical glyphs (½??, etc) I know I could do
those with regular text and the Wingdings font, but that's not available
on every computer, and breaks the semantic meaning behind the glyphs.

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] Convert UTF-8 to PHP defines

2010-05-27 Thread Guus Ellenkamp
I would like if you stick to the original issue: can a PHP source file be in 
utf-8. It's not about the output, that is properly supported.

Think it would be a good idea anyhow that PHP would support utf-8 source 
files as it seems utf-8 is going to be the de-facto standard for text files 
anyhow.

"Ashley Sheridan"  wrote in message 
news:1274988834.2202.285.ca...@localhost...
> On Thu, 2010-05-27 at 15:28 -0400, Bob McConnell wrote:
>
>> From: tedd
>>
>> > The Unicode database uses the same lower
>> > character values (i.e., "code points") as does
>> > ASCII, namely 0-127, and thus UFT-8 (8-bit
>> > variable width encoding) is really a super-set
>> > which includes the sub-set of ASCII.
>> >
>> > The "Wingdings" font that Ash refers to is the
>> > really the "Dingbat" char set in Unicode, as
>> > shown here:
>> >
>> > The use of UFT-8 encoding in everything (web and
>> > php) should present much less problems globally
>> > than it is trying to fight it.
>>
>> Thanks tedd,
>>
>> The real question is whether unicode is even relevant now that the UTF
>> series is available. I see no reason to have to deal with two competing
>> "specifications", when one of them is more than adequate for the job and
>> the other is not even finished yet. That's like the old days when a few
>> users demanded we support both ASCII and EBCDIC. That didn't get very
>> far either.
>>
>> Bob McConnell
>>
>
>
> Bob, UTF is unicode (Unicode Transformation Format)
>
> Interesting enough to note, and not sure if Tedd knows this or not (he
> probably does!) but Chrome has a nice feature for those punycode URLs;
> it suggests the actual real URL instead once you type the domain in. Not
> sure about Safari right now, couldn't be bothered to fire up a VM just
> to check. I would assume Firefox handles these URLs well enough too.
>
> Tedd, does that URL actually go anywhere, as I got nothing when I tried
> visiting it, both the actual URL and the punycode version.
>
> 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] Convert UTF-8 to PHP defines

2010-05-27 Thread Ashley Sheridan
On Fri, 2010-05-28 at 11:51 +0800, Guus Ellenkamp wrote:

> I would like if you stick to the original issue: can a PHP source file be in 
> utf-8. It's not about the output, that is properly supported.
> 
> Think it would be a good idea anyhow that PHP would support utf-8 source 
> files as it seems utf-8 is going to be the de-facto standard for text files 
> anyhow.
> 
> "Ashley Sheridan"  wrote in message 
> news:1274988834.2202.285.ca...@localhost...
> > On Thu, 2010-05-27 at 15:28 -0400, Bob McConnell wrote:
> >
> >> From: tedd
> >>
> >> > The Unicode database uses the same lower
> >> > character values (i.e., "code points") as does
> >> > ASCII, namely 0-127, and thus UFT-8 (8-bit
> >> > variable width encoding) is really a super-set
> >> > which includes the sub-set of ASCII.
> >> >
> >> > The "Wingdings" font that Ash refers to is the
> >> > really the "Dingbat" char set in Unicode, as
> >> > shown here:
> >> >
> >> > The use of UFT-8 encoding in everything (web and
> >> > php) should present much less problems globally
> >> > than it is trying to fight it.
> >>
> >> Thanks tedd,
> >>
> >> The real question is whether unicode is even relevant now that the UTF
> >> series is available. I see no reason to have to deal with two competing
> >> "specifications", when one of them is more than adequate for the job and
> >> the other is not even finished yet. That's like the old days when a few
> >> users demanded we support both ASCII and EBCDIC. That didn't get very
> >> far either.
> >>
> >> Bob McConnell
> >>
> >
> >
> > Bob, UTF is unicode (Unicode Transformation Format)
> >
> > Interesting enough to note, and not sure if Tedd knows this or not (he
> > probably does!) but Chrome has a nice feature for those punycode URLs;
> > it suggests the actual real URL instead once you type the domain in. Not
> > sure about Safari right now, couldn't be bothered to fire up a VM just
> > to check. I would assume Firefox handles these URLs well enough too.
> >
> > Tedd, does that URL actually go anywhere, as I got nothing when I tried
> > visiting it, both the actual URL and the punycode version.
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> > 
> 
> 
> 


Yes is the quick answer.

There's no better way than to try it yourself.

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