php-general Digest 25 Apr 2010 00:04:05 -0000 Issue 6710
Topics (messages 304511 through 304531):
Re: Structured PHP studying
304511 by: David McGlone
304517 by: Jason Pruim
304518 by: Ashley Sheridan
304528 by: Nathan Rixham
304529 by: Ashley Sheridan
Question: Farsi characters showing as jibberish
304512 by: Parham Doustdar
304513 by: Michiel Sikma
304516 by: Ashley Sheridan
304519 by: Parham Doustdar
304521 by: Ashley Sheridan
304525 by: Parham Doustdar
304526 by: Michiel Sikma
304527 by: Parham Doustdar
Re: replying to list (I give up)
304514 by: Michiel Sikma
304515 by: Ashley Sheridan
304522 by: Per Jessen
304523 by: Ashley Sheridan
304524 by: Michiel Sikma
Re: htmlentitites ENT_QUOTES in HTML attributes?
304520 by: Michiel Sikma
PHP not being read?
304530 by: Gary
304531 by: Michiel Sikma
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
On Friday 23 April 2010 10:15:46 Paul M Foster wrote:
> On Fri, Apr 23, 2010 at 07:15:11AM -0400, David McGlone wrote:
> > Is there a good strategy to studying PHP?
> >
> > For instance, is there a way to break everything down into small
> > managable topics?
>
> Obviously, a good book will help. I'd recommend O'Reilly's "Programming
> PHP". Some of this also depends on whether you have a background in
> programming. It's easier if you already know how to code in a different
> language; then you really mostly need to know the differences between
> the languages.
>
> If you want to learn without the benefit of a book, then I'd suggest
> looking over existing beginning programming books for various languages.
> My observation is that they generally follow a pattern. They deal with
> variable naming and types, then legal operations on those types, then
> control structures, then functions, etc. (That may not be accurate; as I
> said, look over the books themselves.) Most/all of this information can
> be obtained from the php.net site.
>
> Ashley's suggestion of coding a project is an outstanding idea. Coding
> is a practical art, and requires practical application to be worth
> anything.
I have coded a couple sites. One for my brother-in-law, but I hate that site
so bad, I'm ashamed to even say I did it.
He chose the layout and colors and told me exactly where he wanted everything,
and it's IMHO absolutely horrible.
There is some code that I wrote for that site that did make me feel good for
coming up with and although it works, most of the code for that site gets on
my nerves. It gives me the feeling that it's very unorganized, and poorly
written.
--
Blessings,
David M.
--- End Message ---
--- Begin Message ---
On Apr 24, 2010, at 7:14 AM, David McGlone wrote:
On Friday 23 April 2010 07:45:16 Michiel Sikma wrote:
On 23 April 2010 13:15, David McGlone <da...@dmcentral.net> wrote:
Is there a good strategy to studying PHP?
For instance, is there a way to break everything down into small
managable topics?
--
Blessings,
David M.
Just build what you want to build and look things up when
necessary. The
biggest part of learning any language is becoming able to
creatively solve
problems within its realm of possibilities, and that's something
you can't
really learn just by reading and solving textbook problems. Hands-on
experience is a very important key to understanding.
Keep an open mind, ask people for answers if things get difficult,
always
assume that there's a better way to do something, and in a while
you'll be
able to write perfectly decent programs.
This is the route I have been following for the past couple years
and I have
always assumed there is a better way to do something and that is, in
a way
what makes me lose confidence.
I always feel like my code is crap and sometimes even ashamed to
even show any
of it.
I feel the some way sometimes... when I look back on some of the stuff
that I wrote when I first started compared to today.... it's amazing
the difference in such a short period of time... But I take comfort in
knowing that I have stuff looking nicer then it was when I started...
I'm making progress :)
--- End Message ---
--- Begin Message ---
On Sat, 2010-04-24 at 07:14 -0400, David McGlone wrote:
> On Friday 23 April 2010 07:45:16 Michiel Sikma wrote:
> > On 23 April 2010 13:15, David McGlone <da...@dmcentral.net> wrote:
> > > Is there a good strategy to studying PHP?
> > >
> > > For instance, is there a way to break everything down into small
> > > managable topics?
> > >
> > > --
> > > Blessings,
> > > David M.
> >
> > Just build what you want to build and look things up when necessary. The
> > biggest part of learning any language is becoming able to creatively solve
> > problems within its realm of possibilities, and that's something you can't
> > really learn just by reading and solving textbook problems. Hands-on
> > experience is a very important key to understanding.
> >
> > Keep an open mind, ask people for answers if things get difficult, always
> > assume that there's a better way to do something, and in a while you'll be
> > able to write perfectly decent programs.
>
> This is the route I have been following for the past couple years and I have
> always assumed there is a better way to do something and that is, in a way
> what makes me lose confidence.
>
> I always feel like my code is crap and sometimes even ashamed to even show
> any
> of it.
>
> --
> Blessings,
> David M.
>
For personal sites, I think as long as the code works, and doesn't have
any glaringly obvious security holes in, then it should be fine.
Personal sites tend not to have a huge amount of traffic, so speed
doesn't really become an issue unless you're doing something totally
crazy (like generating all of your header images on the fly with PHP for
example without any caching)
For commercial sites, more time should be spent on security and testing,
and working over things in your head about how the site is going to get
used. If an area of the site that you feel is going to be very popular
will be busy, then is creating a lot of large objects and making many DB
calls such a great idea?
I look at some code I did a while back and shudder. It started off well
enough, but then feature creep set in and now it looks like a creation
of Frankenstein! I think it happens to all of us at some point, it just
depends how well we deal with it. I'd rather have less then stellar code
than have to tell a client it's going to take more time to add a feature
and then have them go elsewhere.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
David McGlone wrote:
> On Friday 23 April 2010 07:45:16 Michiel Sikma wrote:
>> On 23 April 2010 13:15, David McGlone <da...@dmcentral.net> wrote:
>>> Is there a good strategy to studying PHP?
>>>
>>> For instance, is there a way to break everything down into small
>>> managable topics?
>>>
>>> --
>>> Blessings,
>>> David M.
>> Just build what you want to build and look things up when necessary. The
>> biggest part of learning any language is becoming able to creatively solve
>> problems within its realm of possibilities, and that's something you can't
>> really learn just by reading and solving textbook problems. Hands-on
>> experience is a very important key to understanding.
>>
>> Keep an open mind, ask people for answers if things get difficult, always
>> assume that there's a better way to do something, and in a while you'll be
>> able to write perfectly decent programs.
>
> This is the route I have been following for the past couple years and I have
> always assumed there is a better way to do something and that is, in a way
> what makes me lose confidence.
>
> I always feel like my code is crap and sometimes even ashamed to even show
> any
> of it.
>
Hi David,
Really good to see somebody asking for honest advice on a v important
matter :)
First, if I may, I'd like to suggest that being ashamed to show your
code is never going to be a productive way to work, rather the more code
you show, the more feedback you will get on your code, and often with
examples of alternative ways to do it - posting snippets and
opensourcing are great ways of crowd sourcing solid feedback.
Next, saying your code is crap, we all feel like that sometimes, but
it's critical to note that if your code does the job it's supposed to,
then it's a success! A few months ago I was questioning myself again and
wrote this: http://webr3.org/blog/general/the-wall/ - the point is it's
a good thing to question yourself, it's a good thing to take everything
in to consideration, and often I (used to) find myself looking at very
short procedural ways of doing things and think.. "why am i making all
these classes"; it's our job as programmers to know when to implement
something in 10 quick lines that are easy to maintain, and when to
create an all singing and dancing framework type affair, pros and cons
to each, and there is no "One True Way" TM of doing things - each bit of
code is very much dependent on context, scenario and maintenance costs.
Okay, on to your specific questions!
We can break this down in to small(~ish) common junks, and which you
study, take further and in what order is entirely up to you:
General Coding
This is the stuff that translates to almost every language, for loops,
echo'ing, simple code optimisation and basically just how to script and
program - I'll assume that after two years you've got this nailed better
than any book can teach you, from here it's just experience and picking
up tricks on the way, so generally no need to worry!
PHP
As you know php is a specific language, and the best way to learn
everything php specific, is literally to read the manual, from start to
finish, a few times, and keep referring back to it, if you see something
you haven't actually used before then give it a quick go in a short 5-10
line script and have a play, the 2 minutes it takes will be more than
worth it (by doing it, it'll get engrained in you).
Aside: in every project i do, and at all times i have a test.php where I
literally just try out ways of doing things and snippets of code, once
I'm done i stick an exit; before it then do the next snippet above it,
this way i always have one nice file of snippets in every project to
refer back to - they often come in handy for helping on this list
actually, and in fact sometimes are from peoples code on this list!
Coding Standards
One of the biggest factors of feeling your code isn't good enough, is by
not using any coding standards, this is pretty simple stuff but makes
your life a lot easier, and code a lot cleaner - even crap broken code
comes across a lot better when it's nicely formatted lol. A good IDE can
help you here, as for which coding standards that's up to you, but you
can check you are adhering to them by using "php code sniffer" -
personally I opt for a slightly modified version of zend coding
standards with the odd bit of extra spacing around params etc.
Paradigms & Design Patterns
A bit of familiarity with programming paradigms is always a good thing
http://en.wikipedia.org/wiki/Programming_paradigm
In PHP we use Procedural and Object Orientated (Class Based)
If you do OO then it's also very very useful to read up on all the
Object Orientated subjects though especially "Separation of Concerns",
familiarity of Martin Fowler's enterprise patterns
http://martinfowler.com/ is also a good thing, there is also a Java
pattern guide that's most useful
http://java.sun.com/blueprints/patterns/ and many transfer over to OO PHP.
Other Languages
Yes :) one of the best ways to get good with your primary language (php)
is to try out and use other languages, for instance if you were to put
some focus in to javascript (ecmascript), scala, erlang, c, java and
maybe something like as3 then I'm pretty sure your code and programming
would improve ten fold I'm sure - I'm not suggesting you learn them all
but a bit of focus and playing from time to time would be a very good
thing indeed!
HTTP and REST
This is pretty critical if you're making websites, honestly how can we
create th web if we don't know how it works? REST is the design behind
HTTP (and not just some weirdy api where you use GET parameters) - in
fact when i say pretty critical i mean it's entirely critical, the more
you understand REST and the more familiar you are with HTTP then the
better your websites, web apps, api's etc will be!
HTTP: http://www.w3.org/Protocols/rfc2616/rfc2616.html
HTTPbis (the updated version, work in progress, probably better to read
to be honest): http://tools.ietf.org/wg/httpbis/
Architecture of the worldwide web: http://www.w3.org/TR/webarch/
)you can't argue w/ the makers of the web now can ya)
REST: http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm
leave it there.. but happy to continue if you need.
Best,
Nathan
--- End Message ---
--- Begin Message ---
On Sat, 2010-04-24 at 15:46 +0100, Nathan Rixham wrote:
> David McGlone wrote:
> > On Friday 23 April 2010 07:45:16 Michiel Sikma wrote:
> >> On 23 April 2010 13:15, David McGlone <da...@dmcentral.net> wrote:
> >>> Is there a good strategy to studying PHP?
> >>>
> >>> For instance, is there a way to break everything down into small
> >>> managable topics?
> >>>
> >>> --
> >>> Blessings,
> >>> David M.
> >> Just build what you want to build and look things up when necessary. The
> >> biggest part of learning any language is becoming able to creatively solve
> >> problems within its realm of possibilities, and that's something you can't
> >> really learn just by reading and solving textbook problems. Hands-on
> >> experience is a very important key to understanding.
> >>
> >> Keep an open mind, ask people for answers if things get difficult, always
> >> assume that there's a better way to do something, and in a while you'll be
> >> able to write perfectly decent programs.
> >
> > This is the route I have been following for the past couple years and I
> > have
> > always assumed there is a better way to do something and that is, in a way
> > what makes me lose confidence.
> >
> > I always feel like my code is crap and sometimes even ashamed to even show
> > any
> > of it.
> >
>
> Hi David,
>
> Really good to see somebody asking for honest advice on a v important
> matter :)
>
> First, if I may, I'd like to suggest that being ashamed to show your
> code is never going to be a productive way to work, rather the more code
> you show, the more feedback you will get on your code, and often with
> examples of alternative ways to do it - posting snippets and
> opensourcing are great ways of crowd sourcing solid feedback.
>
> Next, saying your code is crap, we all feel like that sometimes, but
> it's critical to note that if your code does the job it's supposed to,
> then it's a success! A few months ago I was questioning myself again and
> wrote this: http://webr3.org/blog/general/the-wall/ - the point is it's
> a good thing to question yourself, it's a good thing to take everything
> in to consideration, and often I (used to) find myself looking at very
> short procedural ways of doing things and think.. "why am i making all
> these classes"; it's our job as programmers to know when to implement
> something in 10 quick lines that are easy to maintain, and when to
> create an all singing and dancing framework type affair, pros and cons
> to each, and there is no "One True Way" TM of doing things - each bit of
> code is very much dependent on context, scenario and maintenance costs.
>
> Okay, on to your specific questions!
>
> We can break this down in to small(~ish) common junks, and which you
> study, take further and in what order is entirely up to you:
>
> General Coding
> This is the stuff that translates to almost every language, for loops,
> echo'ing, simple code optimisation and basically just how to script and
> program - I'll assume that after two years you've got this nailed better
> than any book can teach you, from here it's just experience and picking
> up tricks on the way, so generally no need to worry!
>
> PHP
> As you know php is a specific language, and the best way to learn
> everything php specific, is literally to read the manual, from start to
> finish, a few times, and keep referring back to it, if you see something
> you haven't actually used before then give it a quick go in a short 5-10
> line script and have a play, the 2 minutes it takes will be more than
> worth it (by doing it, it'll get engrained in you).
>
> Aside: in every project i do, and at all times i have a test.php where I
> literally just try out ways of doing things and snippets of code, once
> I'm done i stick an exit; before it then do the next snippet above it,
> this way i always have one nice file of snippets in every project to
> refer back to - they often come in handy for helping on this list
> actually, and in fact sometimes are from peoples code on this list!
>
> Coding Standards
> One of the biggest factors of feeling your code isn't good enough, is by
> not using any coding standards, this is pretty simple stuff but makes
> your life a lot easier, and code a lot cleaner - even crap broken code
> comes across a lot better when it's nicely formatted lol. A good IDE can
> help you here, as for which coding standards that's up to you, but you
> can check you are adhering to them by using "php code sniffer" -
> personally I opt for a slightly modified version of zend coding
> standards with the odd bit of extra spacing around params etc.
>
> Paradigms & Design Patterns
> A bit of familiarity with programming paradigms is always a good thing
> http://en.wikipedia.org/wiki/Programming_paradigm
> In PHP we use Procedural and Object Orientated (Class Based)
> If you do OO then it's also very very useful to read up on all the
> Object Orientated subjects though especially "Separation of Concerns",
> familiarity of Martin Fowler's enterprise patterns
> http://martinfowler.com/ is also a good thing, there is also a Java
> pattern guide that's most useful
> http://java.sun.com/blueprints/patterns/ and many transfer over to OO PHP.
>
> Other Languages
> Yes :) one of the best ways to get good with your primary language (php)
> is to try out and use other languages, for instance if you were to put
> some focus in to javascript (ecmascript), scala, erlang, c, java and
> maybe something like as3 then I'm pretty sure your code and programming
> would improve ten fold I'm sure - I'm not suggesting you learn them all
> but a bit of focus and playing from time to time would be a very good
> thing indeed!
>
> HTTP and REST
> This is pretty critical if you're making websites, honestly how can we
> create th web if we don't know how it works? REST is the design behind
> HTTP (and not just some weirdy api where you use GET parameters) - in
> fact when i say pretty critical i mean it's entirely critical, the more
> you understand REST and the more familiar you are with HTTP then the
> better your websites, web apps, api's etc will be!
> HTTP: http://www.w3.org/Protocols/rfc2616/rfc2616.html
> HTTPbis (the updated version, work in progress, probably better to read
> to be honest): http://tools.ietf.org/wg/httpbis/
> Architecture of the worldwide web: http://www.w3.org/TR/webarch/
> )you can't argue w/ the makers of the web now can ya)
> REST: http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm
>
> leave it there.. but happy to continue if you need.
>
> Best,
>
> Nathan
>
Great email and nice article. I agree, there is no true way. Just as an
app could be developed in one of a selection of languages, so too the
approach within those languages will differ.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
Hi,
I have created a PHP file, and wrote a string of Farsi letters in it. In the
head section of the HTML, I put:
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
There appears to be something wrong with Apache, or something, because no
matter whether I put that string in an echo statement or just in an HTML
with a php extention, the page loads as jibberish and I have to set the
character encoding to UTF-8 manually in Firefox.
Renaming that same file to .htm (when not using the echo statement), and
loading it in the browser shows me the correct Farsi characters.
Should I change something in Apache's settings for this to work?
Thanks!
--- End Message ---
--- Begin Message ---
On 24 April 2010 14:45, Parham Doustdar <parha...@gmail.com> wrote:
> Hi,
>
> I have created a PHP file, and wrote a string of Farsi letters in it. In
> the
> head section of the HTML, I put:
>
> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
>
> There appears to be something wrong with Apache, or something, because no
> matter whether I put that string in an echo statement or just in an HTML
> with a php extention, the page loads as jibberish and I have to set the
> character encoding to UTF-8 manually in Firefox.
>
> Renaming that same file to .htm (when not using the echo statement), and
> loading it in the browser shows me the correct Farsi characters.
>
> Should I change something in Apache's settings for this to work?
>
> Thanks!
>
>
> No, that should work perfectly fine. Are you sure that the PHP file itself
is utf-8?
Could it be that you manually set the text encoding to something else in
your browser, causing it to remember that setting?
Perhaps you could link us to the page itself so we can have a look. Note
that the best place to put that <meta> tag is right after the opening <head>
tag, before any other header information.
Michiel
--- End Message ---
--- Begin Message ---
On Sat, 2010-04-24 at 15:38 +0200, Michiel Sikma wrote:
> On 24 April 2010 14:45, Parham Doustdar <parha...@gmail.com> wrote:
>
> > Hi,
> >
> > I have created a PHP file, and wrote a string of Farsi letters in it. In
> > the
> > head section of the HTML, I put:
> >
> > <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
> >
> > There appears to be something wrong with Apache, or something, because no
> > matter whether I put that string in an echo statement or just in an HTML
> > with a php extention, the page loads as jibberish and I have to set the
> > character encoding to UTF-8 manually in Firefox.
> >
> > Renaming that same file to .htm (when not using the echo statement), and
> > loading it in the browser shows me the correct Farsi characters.
> >
> > Should I change something in Apache's settings for this to work?
> >
> > Thanks!
> >
> >
> > No, that should work perfectly fine. Are you sure that the PHP file itself
> is utf-8?
> Could it be that you manually set the text encoding to something else in
> your browser, causing it to remember that setting?
>
> Perhaps you could link us to the page itself so we can have a look. Note
> that the best place to put that <meta> tag is right after the opening <head>
> tag, before any other header information.
>
> Michiel
If renaming the file as .htm shows the characters correctly, then
the .php file is most likely saved as utf8.
Maybe Apache has been instructed to send all HTML with another encoding,
as it should send it out with the same encoding as the requested PHP
script.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
Hi Ashley and Michiel,
It appears it is something in Apache or my server program on Windows (I am
using Uniform Server; a portable webserver from
http://www.uniformserver.com). The reason I got to such a conclusion is
this:
1. I uploaded the pHP file to a free hosting website. Here is the URL:
http://blindmoviebuff.uphero.com/test2.php
2. I put the same page in my www folder in Windows. Here's the address to
that:
http://parham-d.dyndns.org/test2.php
As you can see, the page on uphero.com displays without any encoding changes
required by you, whereas the second has to be manual (for some reason). I
thought seeing the UTF-8 made the browser use that encoding automatically
regardless of whether or not it was sent in UTF-8?
Sorry, I have no information at all about how transmiting is handled. Just
saying guesses aloud. :-)
----- Original Message -----
From: "Ashley Sheridan" <a...@ashleysheridan.co.uk>
Newsgroups: php.general
To: "Michiel Sikma" <mich...@thingmajig.org>
Cc: "Parham Doustdar" <parha...@gmail.com>; <php-gene...@lists.php.net>
Sent: Saturday, April 24, 2010 6:16 PM
Subject: Re: [PHP] Question: Farsi characters showing as jibberish
> On Sat, 2010-04-24 at 15:38 +0200, Michiel Sikma wrote:
>
>> On 24 April 2010 14:45, Parham Doustdar <parha...@gmail.com> wrote:
>>
>> > Hi,
>> >
>> > I have created a PHP file, and wrote a string of Farsi letters in it.
>> > In
>> > the
>> > head section of the HTML, I put:
>> >
>> > <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
>> >
>> > There appears to be something wrong with Apache, or something, because
>> > no
>> > matter whether I put that string in an echo statement or just in an
>> > HTML
>> > with a php extention, the page loads as jibberish and I have to set the
>> > character encoding to UTF-8 manually in Firefox.
>> >
>> > Renaming that same file to .htm (when not using the echo statement),
>> > and
>> > loading it in the browser shows me the correct Farsi characters.
>> >
>> > Should I change something in Apache's settings for this to work?
>> >
>> > Thanks!
>> >
>> >
>> > No, that should work perfectly fine. Are you sure that the PHP file
>> > itself
>> is utf-8?
>> Could it be that you manually set the text encoding to something else in
>> your browser, causing it to remember that setting?
>>
>> Perhaps you could link us to the page itself so we can have a look. Note
>> that the best place to put that <meta> tag is right after the opening
>> <head>
>> tag, before any other header information.
>>
>> Michiel
>
>
> If renaming the file as .htm shows the characters correctly, then
> the .php file is most likely saved as utf8.
>
> Maybe Apache has been instructed to send all HTML with another encoding,
> as it should send it out with the same encoding as the requested PHP
> script.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
--- End Message ---
--- Begin Message ---
On Sat, 2010-04-24 at 18:37 +0430, Parham Doustdar wrote:
> Hi Ashley and Michiel,
>
> It appears it is something in Apache or my server program on Windows (I am
> using Uniform Server; a portable webserver from
> http://www.uniformserver.com). The reason I got to such a conclusion is
> this:
>
> 1. I uploaded the pHP file to a free hosting website. Here is the URL:
> http://blindmoviebuff.uphero.com/test2.php
>
> 2. I put the same page in my www folder in Windows. Here's the address to
> that:
> http://parham-d.dyndns.org/test2.php
>
> As you can see, the page on uphero.com displays without any encoding changes
> required by you, whereas the second has to be manual (for some reason). I
> thought seeing the UTF-8 made the browser use that encoding automatically
> regardless of whether or not it was sent in UTF-8?
>
> Sorry, I have no information at all about how transmiting is handled. Just
> saying guesses aloud. :-)
> ----- Original Message -----
> From: "Ashley Sheridan" <a...@ashleysheridan.co.uk>
> Newsgroups: php.general
> To: "Michiel Sikma" <mich...@thingmajig.org>
> Cc: "Parham Doustdar" <parha...@gmail.com>; <php-gene...@lists.php.net>
> Sent: Saturday, April 24, 2010 6:16 PM
> Subject: Re: [PHP] Question: Farsi characters showing as jibberish
>
>
> > On Sat, 2010-04-24 at 15:38 +0200, Michiel Sikma wrote:
> >
> >> On 24 April 2010 14:45, Parham Doustdar <parha...@gmail.com> wrote:
> >>
> >> > Hi,
> >> >
> >> > I have created a PHP file, and wrote a string of Farsi letters in it.
> >> > In
> >> > the
> >> > head section of the HTML, I put:
> >> >
> >> > <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
> >> >
> >> > There appears to be something wrong with Apache, or something, because
> >> > no
> >> > matter whether I put that string in an echo statement or just in an
> >> > HTML
> >> > with a php extention, the page loads as jibberish and I have to set the
> >> > character encoding to UTF-8 manually in Firefox.
> >> >
> >> > Renaming that same file to .htm (when not using the echo statement),
> >> > and
> >> > loading it in the browser shows me the correct Farsi characters.
> >> >
> >> > Should I change something in Apache's settings for this to work?
> >> >
> >> > Thanks!
> >> >
> >> >
> >> > No, that should work perfectly fine. Are you sure that the PHP file
> >> > itself
> >> is utf-8?
> >> Could it be that you manually set the text encoding to something else in
> >> your browser, causing it to remember that setting?
> >>
> >> Perhaps you could link us to the page itself so we can have a look. Note
> >> that the best place to put that <meta> tag is right after the opening
> >> <head>
> >> tag, before any other header information.
> >>
> >> Michiel
> >
> >
> > If renaming the file as .htm shows the characters correctly, then
> > the .php file is most likely saved as utf8.
> >
> > Maybe Apache has been instructed to send all HTML with another encoding,
> > as it should send it out with the same encoding as the requested PHP
> > script.
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> >
>
>
>
Try adding this before any output to the browser:
header('Content-Type: text/html; charset=utf-8');
Which should force the server to send the output in this specific
format.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
Hi again,
That did work, indeed. Now, I guess that means that Apache is outputting the
PHP as something other than UTF-8. In fact, googling, I came up with this
line of .htaccess:
AddDefaultCharset UTF-8
which works perfectly!
Thank you, everyone, for yet again helping me out.
"Ashley Sheridan" <a...@ashleysheridan.co.uk> wrote in message
news:1272117941.20937.164.ca...@localhost...
> On Sat, 2010-04-24 at 18:37 +0430, Parham Doustdar wrote:
>
>> Hi Ashley and Michiel,
>>
>> It appears it is something in Apache or my server program on Windows (I
>> am
>> using Uniform Server; a portable webserver from
>> http://www.uniformserver.com). The reason I got to such a conclusion is
>> this:
>>
>> 1. I uploaded the pHP file to a free hosting website. Here is the URL:
>> http://blindmoviebuff.uphero.com/test2.php
>>
>> 2. I put the same page in my www folder in Windows. Here's the address to
>> that:
>> http://parham-d.dyndns.org/test2.php
>>
>> As you can see, the page on uphero.com displays without any encoding
>> changes
>> required by you, whereas the second has to be manual (for some reason). I
>> thought seeing the UTF-8 made the browser use that encoding automatically
>> regardless of whether or not it was sent in UTF-8?
>>
>> Sorry, I have no information at all about how transmiting is handled.
>> Just
>> saying guesses aloud. :-)
>> ----- Original Message -----
>> From: "Ashley Sheridan" <a...@ashleysheridan.co.uk>
>> Newsgroups: php.general
>> To: "Michiel Sikma" <mich...@thingmajig.org>
>> Cc: "Parham Doustdar" <parha...@gmail.com>; <php-gene...@lists.php.net>
>> Sent: Saturday, April 24, 2010 6:16 PM
>> Subject: Re: [PHP] Question: Farsi characters showing as jibberish
>>
>>
>> > On Sat, 2010-04-24 at 15:38 +0200, Michiel Sikma wrote:
>> >
>> >> On 24 April 2010 14:45, Parham Doustdar <parha...@gmail.com> wrote:
>> >>
>> >> > Hi,
>> >> >
>> >> > I have created a PHP file, and wrote a string of Farsi letters in
>> >> > it.
>> >> > In
>> >> > the
>> >> > head section of the HTML, I put:
>> >> >
>> >> > <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
>> >> >
>> >> > There appears to be something wrong with Apache, or something,
>> >> > because
>> >> > no
>> >> > matter whether I put that string in an echo statement or just in an
>> >> > HTML
>> >> > with a php extention, the page loads as jibberish and I have to set
>> >> > the
>> >> > character encoding to UTF-8 manually in Firefox.
>> >> >
>> >> > Renaming that same file to .htm (when not using the echo statement),
>> >> > and
>> >> > loading it in the browser shows me the correct Farsi characters.
>> >> >
>> >> > Should I change something in Apache's settings for this to work?
>> >> >
>> >> > Thanks!
>> >> >
>> >> >
>> >> > No, that should work perfectly fine. Are you sure that the PHP file
>> >> > itself
>> >> is utf-8?
>> >> Could it be that you manually set the text encoding to something else
>> >> in
>> >> your browser, causing it to remember that setting?
>> >>
>> >> Perhaps you could link us to the page itself so we can have a look.
>> >> Note
>> >> that the best place to put that <meta> tag is right after the opening
>> >> <head>
>> >> tag, before any other header information.
>> >>
>> >> Michiel
>> >
>> >
>> > If renaming the file as .htm shows the characters correctly, then
>> > the .php file is most likely saved as utf8.
>> >
>> > Maybe Apache has been instructed to send all HTML with another
>> > encoding,
>> > as it should send it out with the same encoding as the requested PHP
>> > script.
>> >
>> > Thanks,
>> > Ash
>> > http://www.ashleysheridan.co.uk
>> >
>> >
>> >
>>
>>
>>
>
> Try adding this before any output to the browser:
>
> header('Content-Type: text/html; charset=utf-8');
>
> Which should force the server to send the output in this specific
> format.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
--- End Message ---
--- Begin Message ---
On 24 April 2010 16:07, Parham Doustdar <parha...@gmail.com> wrote:
> Hi Ashley and Michiel,
>
> It appears it is something in Apache or my server program on Windows (I am
> using Uniform Server; a portable webserver from
> http://www.uniformserver.com). The reason I got to such a conclusion is
> this:
>
> 1. I uploaded the pHP file to a free hosting website. Here is the URL:
> http://blindmoviebuff.uphero.com/test2.php
>
> 2. I put the same page in my www folder in Windows. Here's the address to
> that:
> http://parham-d.dyndns.org/test2.php
>
> As you can see, the page on uphero.com displays without any encoding
> changes
> required by you, whereas the second has to be manual (for some reason).
-snip-
>
>
Actually, both of these work fine for me. I don't have to manually set the
encoding to get the Farsi characters to show up in either of these links.
I don't know why it wouldn't work for you. Maybe you should try a different
browser to make sure it isn't a cached setting. Adding the header() call
that Ashley suggested also seems like a good idea.
Michiel
--- End Message ---
--- Begin Message ---
Hi,
It probably did because I added the line,
AddDefaultCharset UTF-8
to my .htaccess a few moments ago. :-)
"Michiel Sikma" <mich...@thingmajig.org> wrote in message
news:o2p6cda1ded1004240726l272f04fbmdd2fb996e2580...@mail.gmail.com...
> On 24 April 2010 16:07, Parham Doustdar <parha...@gmail.com> wrote:
>
>> Hi Ashley and Michiel,
>>
>> It appears it is something in Apache or my server program on Windows (I
>> am
>> using Uniform Server; a portable webserver from
>> http://www.uniformserver.com). The reason I got to such a conclusion is
>> this:
>>
>> 1. I uploaded the pHP file to a free hosting website. Here is the URL:
>> http://blindmoviebuff.uphero.com/test2.php
>>
>> 2. I put the same page in my www folder in Windows. Here's the address to
>> that:
>> http://parham-d.dyndns.org/test2.php
>>
>> As you can see, the page on uphero.com displays without any encoding
>> changes
>> required by you, whereas the second has to be manual (for some reason).
>
> -snip-
>>
>>
>
> Actually, both of these work fine for me. I don't have to manually set the
> encoding to get the Farsi characters to show up in either of these links.
> I don't know why it wouldn't work for you. Maybe you should try a
> different
> browser to make sure it isn't a cached setting. Adding the header() call
> that Ashley suggested also seems like a good idea.
>
> Michiel
>
--- End Message ---
--- Begin Message ---
On 23 April 2010 16:16, Kevin Kinsey <k...@daleco.biz> wrote:
>
> I've still got a Win98 box in service somewhere around here; I use
> it for audio recording. Someone (possibly even me) renamed most
> of the desktop icons ... OE's shortcut is "Outluck Depress". :-)
>
> Kevin D. Kinsey
>
>
Say what you will about Windows 9x systems, but they (and especially Windows
95) ran rather well on just 60 MHz.
Sure, computers are constantly getting faster, but fortunately software
developers keep coming up with new ways to make us wait. :)
Michiel
--- End Message ---
--- Begin Message ---
On Sat, 2010-04-24 at 15:44 +0200, Michiel Sikma wrote:
> On 23 April 2010 16:16, Kevin Kinsey <k...@daleco.biz> wrote:
>
> >
> > I've still got a Win98 box in service somewhere around here; I use
> > it for audio recording. Someone (possibly even me) renamed most
> > of the desktop icons ... OE's shortcut is "Outluck Depress". :-)
> >
> > Kevin D. Kinsey
> >
> >
> Say what you will about Windows 9x systems, but they (and especially Windows
> 95) ran rather well on just 60 MHz.
> Sure, computers are constantly getting faster, but fortunately software
> developers keep coming up with new ways to make us wait. :)
>
> Michiel
Sounds like a decent reason to try Linux then. Linux performs pretty
admirably on older kit.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
Ashley Sheridan wrote:
>>
>> Is there an actual WoW client for Linux or you run in Wine like
>> environment?
>>
>> Thanks,
>> Tommy
>>
>
> I run it under Wine. Wine has come a long way since my first
> encounters with it a few years back and run a surprising amount of
> Windows-based software.
Doesn't WoW need DirectX and all that? I have some old Windows games
(Diablo, Alpha Centauri, Railroad Tycoon, Wolfenstein) I'd love to play
under Wine, but so far I've not managed to make them work.
--
Per Jessen, Zürich (19.7°C)
--- End Message ---
--- Begin Message ---
On Sat, 2010-04-24 at 16:14 +0200, Per Jessen wrote:
> Ashley Sheridan wrote:
>
> >>
> >> Is there an actual WoW client for Linux or you run in Wine like
> >> environment?
> >>
> >> Thanks,
> >> Tommy
> >>
> >
> > I run it under Wine. Wine has come a long way since my first
> > encounters with it a few years back and run a surprising amount of
> > Windows-based software.
>
> Doesn't WoW need DirectX and all that? I have some old Windows games
> (Diablo, Alpha Centauri, Railroad Tycoon, Wolfenstein) I'd love to play
> under Wine, but so far I've not managed to make them work.
>
>
> --
> Per Jessen, Zürich (19.7°C)
>
>
It can use OpenGL too. Just call it like this:
wine Wow.exe -opengl
and it will run in OpenGL mode. The only issue I've noticed is that Wine
doesn't play well when it comes to sound, so I have to turn off things
like Amarok when I want to play WoW.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
On 24 April 2010 16:14, Per Jessen <p...@computer.org> wrote:
> Ashley Sheridan wrote:
>
> >>
> >> Is there an actual WoW client for Linux or you run in Wine like
> >> environment?
> >>
> >> Thanks,
> >> Tommy
> >>
> >
> > I run it under Wine. Wine has come a long way since my first
> > encounters with it a few years back and run a surprising amount of
> > Windows-based software.
>
> Doesn't WoW need DirectX and all that? I have some old Windows games
> (Diablo, Alpha Centauri, Railroad Tycoon, Wolfenstein) I'd love to play
> under Wine, but so far I've not managed to make them work.
>
>
The best way to run old games is via DOSBox. http://www.dosbox.com/ If you
have an Intel machine it should run pretty well (at least the latest version
will; some repos still have the old 0.65 version which is significantly
slower).
Michiel
--- End Message ---
--- Begin Message ---
On 23 April 2010 14:21, Jan G.B. <ro0ot.w...@googlemail.com> wrote:
> Hi List,
>
> I just figured, that the Browsers on my system do interpret '
> inside href or onclick attribute as a plain '.
>
> Imagine the user input is the following line:
>
> param2" foo';);alert(document.cookie);alert('
>
> Which is being written by the script like that:
>
> <a href="javascript:void(0);" onclick="test(1,
> 'USER_INPUT_GOES_HERE');">test</a>
>
> USER_INPUT is sent through htmlentities($str, ENT_QUOTES, 'UTF-8');
>
> The result is the following then:
>
> <html><body>
> <script type="text/javascript">
> function example(a, b) {
> alert('valid alert; params: '+ a+', '+b);
> }
> </script>
>
> <a href="javascript:void(0);" onclick="example(1, 'param2"
> foo');alert(document.cookie);alert('');">test</a>
> </body></html>
>
>
> My browsers will alert the document.cookie.
> Please confirm this (and keep in mind that document.cookie is just
> empty when tested locally).
>
>
> Regards
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Yes, ' is the same as a single quote. But let's say you set up your
page like this:
http://pastie.org/932923
Submitting the form will change the $input variable that's also added to the
Javascript below. So in theory, you should be able to submit, say,
'+window.very_important_variable+' in order to get an alert with
the secret number 255 in it. But when submitting that text in the form, the
& actually gets converted to &, causing the alert() to literally print
the string '. When submitting a real single quote, it gets converted to
\', printing a literal '.
The only way to get to the window.very_important_variable is by removing the
htmlentities() function in the PHP code. The test case you added is
incorrect, since properly sanitized input would never have an actual,
non-escaped ' in it.
Michiel
--- End Message ---
--- Begin Message ---
What would cause a machine not to read/process php?
I have a laptop that I have been ever increasing using for php scripting. I
decided to do a simple experiment, it started out something like:
$seconds=1;
$minutes=$seconds*60;
$hours=$minutes*60;
$days="$hours*24;
echo $seconds;
echo $minutes;
echo $hours;
echo $days;
Nothing showed in the browser on my local server. I then tried various
changes, adding single quotes, double quotes, parenthsis, changing echo to
print....nothing.
Finally, after looking online and through a couples of books, I was able to
get this in the browser:
$minutes"; echo $hours; echo $days; ?>
I also got this in a browser (code not included in this post but you can see
how far back to the basics I went to get this to work).
Hello World'; echo "
$minutes
"; echo $hours; echo $days; ?>
When I sent the file over to my other computer...I got what I thought I was
going to get, numbers and calculations.
What would cause a browser to display the closing tags of php?
I dont know where to begin to look, could this be a setting in my editor
(Dreamweaver CS3), the testing server config file, the browsers?
Thanks for your help.
Gary
__________ Information from ESET NOD32 Antivirus, version of virus signature
database 5057 (20100424) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
--- End Message ---
--- Begin Message ---
On 25 April 2010 00:45, Gary <g...@paulgdesigns.com> wrote:
> What would cause a machine not to read/process php?
>
> I have a laptop that I have been ever increasing using for php scripting.
> I decided to do a simple experiment, it started out something like:
>
> $seconds=1;
> $minutes=$seconds*60;
> $hours=$minutes*60;
> $days="$hours*24;
>
> echo $seconds;
> echo $minutes;
> echo $hours;
> echo $days;
-snip-
>
>
A text editor with syntax highlighting would certainly help. There's a
double quote " right in front of the $hours variable on the fourth line.
That's an unterminated string literal, a syntax error, which would cause PHP
to abort entirely. Your php's error log probably has a message in it to this
extent.
The reason why you got a number of different results is probably because you
added another double quote further down in later versions.
But if that's somehow not it, post the entire source code of your file on a
site like http://pastie.org/ so we can have a closer look.
Michiel
--- End Message ---