php-general Digest 23 Apr 2010 14:15:34 -0000 Issue 6708

Topics (messages 304454 through 304474):

Re: Updating cli executable on MS-Windows
        304454 by: Bob McConnell
        304461 by: Richard Quadling
        304462 by: Richard Quadling

Re: [PHP-INSTALL] Getting file pointer from file descriptor
        304455 by: Rasmus Lerdorf

escape \n
        304456 by: Nick Balestra
        304457 by: Ashley Sheridan
        304458 by: Nick Balestra
        304471 by: Jan G.B.

PHP can't find OCI.dll
        304459 by: Darren Karstens

Re: Math Question....
        304460 by: Richard Quadling
        304472 by: Dotan Cohen
        304473 by: Richard Quadling

public readonly variables
        304463 by: Ashley Sheridan
        304464 by: Richard Quadling

Structured PHP studying
        304465 by: David McGlone
        304466 by: Peter Lind
        304467 by: Ashley Sheridan
        304468 by: Michiel Sikma
        304469 by: Jay Ess
        304474 by: Paul M Foster

htmlentitites ENT_QUOTES in HTML attributes?
        304470 by: Jan G.B.

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 ---
From: Richard Quadling
> On 22 April 2010 14:42, Bob McConnell <r...@cbord.com> wrote:
>> I downloaded the MS-Windows cli from The PHP Group a while ago. It
>> claims to be version 5.2.10. But now I can't find where I got it, nor
>> where to get the updates. What is the easiest way to upgrade it to
>> 5.2.13?
>>
>>  D:\Code\Tests>php --version
>>  PHP 5.2.10 (cli) (built: Jun 17 2009 16:16:57)
>>  Copyright (c) 1997-2009 The PHP Group
>>  Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
>>
>> Bob McConnell
> 
> You can get the latest V5.2.x from http://windows.php.net/download/

Which one has just the cli installer? I don't want any server files installed 
on my workstation.

Bob McConnell

--- End Message ---
--- Begin Message ---
On 23 April 2010 02:34, Bob McConnell <r...@cbord.com> wrote:
> From: Richard Quadling
>> On 22 April 2010 14:42, Bob McConnell <r...@cbord.com> wrote:
>>> I downloaded the MS-Windows cli from The PHP Group a while ago. It
>>> claims to be version 5.2.10. But now I can't find where I got it, nor
>>> where to get the updates. What is the easiest way to upgrade it to
>>> 5.2.13?
>>>
>>>  D:\Code\Tests>php --version
>>>  PHP 5.2.10 (cli) (built: Jun 17 2009 16:16:57)
>>>  Copyright (c) 1997-2009 The PHP Group
>>>  Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
>>>
>>> Bob McConnell
>>
>> You can get the latest V5.2.x from http://windows.php.net/download/
>
> Which one has just the cli installer? I don't want any server files installed 
> on my workstation.
>
> Bob McConnell
>

PHP on windows, fundamentally, consists of a series of dlls
(extensions), a runtime (php5.dll), supporting dlls (used by the
extensions), and then the SAPI files (php.exe, php-cgi.exe).

The only element that is "server" related, would be php-cgi.exe and
for older versions of PHP, php5isapi.dll. There are other SAPIs (ways
of running PHP).

The SAPI files are small as all they do is sit between the executing
environment and php5.dll.

So. Don't worry about them.

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

--- End Message ---
--- Begin Message ---
On 23 April 2010 02:34, Bob McConnell <r...@cbord.com> wrote:
> From: Richard Quadling
>> On 22 April 2010 14:42, Bob McConnell <r...@cbord.com> wrote:
>>> I downloaded the MS-Windows cli from The PHP Group a while ago. It
>>> claims to be version 5.2.10. But now I can't find where I got it, nor
>>> where to get the updates. What is the easiest way to upgrade it to
>>> 5.2.13?
>>>
>>>  D:\Code\Tests>php --version
>>>  PHP 5.2.10 (cli) (built: Jun 17 2009 16:16:57)
>>>  Copyright (c) 1997-2009 The PHP Group
>>>  Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
>>>
>>> Bob McConnell
>>
>> You can get the latest V5.2.x from http://windows.php.net/download/
>
> Which one has just the cli installer? I don't want any server files installed 
> on my workstation.
>
> Bob McConnell
>

Normally, you take the ZIP file and unzip it into C:\PHP5 (or wherever
you want).

That's the installation done.

Then, you take a long look through the php.ini-production and
php.ini-development to see what you need to setup.

I'd recommend reading ...

http://docs.php.net/manual/en/install.windows.manual.php
and
http://docs.php.net/manual/en/install.windows.commandline.php


-- 
-----
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

--- End Message ---
--- Begin Message ---
You seem to be quite confused.  First of all, a function like fdopen() which
has never existed in any version of PHP, wouldn't read/write anything.  In C
that function will return a FILE pointer from a file descriptor.  You would
then use fread()/fwrite() to read and write from that FILE pointer.  But PHP
doesn't have file pointers nor file descriptors, so none of this applies to
PHP.  In PHP an open file is a resource just like an open database
connection is a resource.

So, is your question really how to read and write to files?  There are many
ways to do that.  The easiest is to just call
file_get_contents()/file_put_contents(), but you can also use
fopen()/fread()/fwrite() if you prefer that approach.

-Rasmus

On Fri, Apr 16, 2010 at 5:15 AM, Naga Kiran K <k.nagaki...@gmail.com> wrote:

> Hi Rasmus,
>
> Thanks for reply.
> The requirement I was looking for is to read/write given only the file
> descriptor number.
>
> PHP-CGI binary is invoked by a webserver that runs in jail-directory and
> doesn't have access to the file path directory.
> So, it communicates with another daemon that opens a socket to that file
> and in turn passes the file descriptor alone.
>
> Can you please suggest if there is any API in PHP that serves this
> requirement [read/write to given file descriptor]
> Please let me know if I need to provide more information.
>
> Thanks,
> Naga Kiran
>
>
> On Thu, Apr 15, 2010 at 7:33 PM, Rasmus Lerdorf <ras...@lerdorf.com>wrote:
>
>> On 04/15/2010 06:52 AM, Naga Kiran K wrote:
>> > Hi,
>> >
>> > We are upgrading PHP from 5.2.3 to 5.3.2 and are facing few issues [like
>> > unsupported functions...]
>> >
>> > In PHP 5.2.3, "fdopen" was used to read/write to a file descriptor
>> > that's opened by another application.
>> >
>> > fdopen(<fileDescriptorId>,"rw");  //It worked fine with PHP 5.2.3
>> >
>> > After PHP upgrade,its throwing "undefined reference to 'fdopen'
>> function".
>> >
>> > Please suggest whats the replacement for this in PHP 5.2.3 or any
>> > workaround.
>>
>> PHP has never had an fdopen() function.  It must be something in user
>> space that provided that for you if you had it.
>>
>> -Rasmus
>>
>
>
>
> --
> Regards,
> Naga Kiran
>

--- End Message ---
--- Begin Message ---
Hello guys i am trying to figure out what is worng with thoose special escaped 
character, like \n \t \r ...

As i cannot make them working. The browser doesn't display them, but doesn't 
eithr crate a new line, or else.
I am using them fro example like this:

print: "this shoudl be on a line \nwhile this on a new line";

I've searched google and saw man people struggling with this, but apparently 
not a clear answer to why....maybe is a stupid beginner question, but i would 
just like to know.  (Personally i solved for the moment by printing out <br> or 
<pre>, but i would like to understand this.

Cheers, Nick

--- End Message ---
--- Begin Message ---
On Fri, 2010-04-23 at 09:51 +0200, Nick Balestra wrote:

> Hello guys i am trying to figure out what is worng with thoose special 
> escaped character, like \n \t \r ...
> 
> As i cannot make them working. The browser doesn't display them, but doesn't 
> eithr crate a new line, or else.
> I am using them fro example like this:
> 
> print: "this shoudl be on a line \nwhile this on a new line";
> 
> I've searched google and saw man people struggling with this, but apparently 
> not a clear answer to why....maybe is a stupid beginner question, but i would 
> just like to know.  (Personally i solved for the moment by printing out <br> 
> or <pre>, but i would like to understand this.
> 
> Cheers, Nick


By default, PHP sends out HTML headers. Browsers ignore extraneous
white-space characters, and also new lines, carriage returns and tabs,
converting them all to a single space character.

If you view the source in your browser, you'll see the newlines, but in
regular display, your text is treated as HTML.

There is a function in PHP called nl2br, which accepts a string and
returns the same one with all the newlines replaced with <br>
automatically, which might be easier to use if your content is in a
string. Otherwise, the only way to get new lines on your actual page is
to either manually use <br> tags, put the text inside a <pre> block, or
use CSS to preserve the white-space.

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



--- End Message ---
--- Begin Message ---
Thanks everybody!

On Apr 23, 2010, at 10:05 AM, Ashley Sheridan wrote:

> On Fri, 2010-04-23 at 09:51 +0200, Nick Balestra wrote:
>> 
>> Hello guys i am trying to figure out what is worng with thoose special 
>> escaped character, like \n \t \r ...
>> 
>> As i cannot make them working. The browser doesn't display them, but doesn't 
>> eithr crate a new line, or else.
>> I am using them fro example like this:
>> 
>> print: "this shoudl be on a line \nwhile this on a new line";
>> 
>> I've searched google and saw man people struggling with this, but apparently 
>> not a clear answer to why....maybe is a stupid beginner question, but i 
>> would just like to know.  (Personally i solved for the moment by printing 
>> out <br> or <pre>, but i would like to understand this.
>> 
>> Cheers, Nick
> 
> By default, PHP sends out HTML headers. Browsers ignore extraneous 
> white-space characters, and also new lines, carriage returns and tabs, 
> converting them all to a single space character.
> 
> If you view the source in your browser, you'll see the newlines, but in 
> regular display, your text is treated as HTML.
> 
> There is a function in PHP called nl2br, which accepts a string and returns 
> the same one with all the newlines replaced with <br> automatically, which 
> might be easier to use if your content is in a string. Otherwise, the only 
> way to get new lines on your actual page is to either manually use <br> tags, 
> put the text inside a <pre> block, or use CSS to preserve the white-space.
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
> 
> 


--- End Message ---
--- Begin Message ---
You can also just send out the correct Header for plain text. But your
HTMl will not be interpreted then.. So this makes only sense if you
actually want plain text as the output format.

header("Content-type: text/plain; charset=utf8");
echo "foo\nbar";


Regards

2010/4/23 Nick Balestra <n...@beyounic.com>:
> Thanks everybody!
>
> On Apr 23, 2010, at 10:05 AM, Ashley Sheridan wrote:
>
>> On Fri, 2010-04-23 at 09:51 +0200, Nick Balestra wrote:
>>>
>>> Hello guys i am trying to figure out what is worng with thoose special 
>>> escaped character, like \n \t \r ...
>>>
>>> As i cannot make them working. The browser doesn't display them, but 
>>> doesn't eithr crate a new line, or else.
>>> I am using them fro example like this:
>>>
>>> print: "this shoudl be on a line \nwhile this on a new line";
>>>
>>> I've searched google and saw man people struggling with this, but 
>>> apparently not a clear answer to why....maybe is a stupid beginner 
>>> question, but i would just like to know.  (Personally i solved for the 
>>> moment by printing out <br> or <pre>, but i would like to understand this.
>>>
>>> Cheers, Nick
>>
>> By default, PHP sends out HTML headers. Browsers ignore extraneous 
>> white-space characters, and also new lines, carriage returns and tabs, 
>> converting them all to a single space character.
>>
>> If you view the source in your browser, you'll see the newlines, but in 
>> regular display, your text is treated as HTML.
>>
>> There is a function in PHP called nl2br, which accepts a string and returns 
>> the same one with all the newlines replaced with <br> automatically, which 
>> might be easier to use if your content is in a string. Otherwise, the only 
>> way to get new lines on your actual page is to either manually use <br> 
>> tags, put the text inside a <pre> block, or use CSS to preserve the 
>> white-space.
>>
>> Thanks,
>> Ash
>> http://www.ashleysheridan.co.uk
>>
>>
>
>

--- End Message ---
--- Begin Message ---
Hi,
I have just installed PHP and Oracle 11.2 on a new server but I get an
error message when I try to run php from the command line saying "This
application has failed to start because OCI.dll was not found". I have
checked that the ORACLE_HOME environment variable is set correctly and
have included the ORACLE_HOM/bin directory (where the OCI.dll is
located) in my path but PHP still cant find it. Does anyone know what
might be causing this?
Regards,
Darren

--- End Message ---
--- Begin Message ---
On 22 April 2010 17:47, Developer Team <d...@thebat.net> wrote:
> Awesome source.
> Thanks
>
> On 4/22/10, Richard Quadling <rquadl...@googlemail.com> wrote:
>> On 22 April 2010 14:48, Dan Joseph <dmjos...@gmail.com> wrote:
>>> On Thu, Apr 22, 2010 at 10:29 AM, Richard Quadling
>>> <rquadl...@googlemail.com
>>>> wrote:
>>>
>>>>  >
>>>> > It sounds like you are looking for factors.
>>>> >
>>>> >
>>>> http://www.algebra.com/algebra/homework/divisibility/factor-any-number-1.solver
>>>> >
>>>> > Solution by Find factors of any number
>>>> >
>>>> > 1252398 is NOT a prime number: 1252398 = 2 * 3 * 7 * 29819
>>>> > Work Shown
>>>> >
>>>> > 1252398 is divisible by 2: 1252398 = 626199 * 2.
>>>> > 626199 is divisible by 3: 626199 = 208733 * 3.
>>>> > 208733 is divisible by 7: 208733 = 29819 * 7.
>>>> > 29819 is not divisible by anything.
>>>> >
>>>> > So 29819 by 42 (7*3*2)
>>>> >
>>>> > would be a route.
>>>>
>>>> Aha. Missed the "30" bit.
>>>>
>>>> So, having found the factors, you would need to process them to find
>>>> the largest combination under 30.
>>>>
>>>> 2*3
>>>> 2*3*7
>>>> 2*7
>>>> 3*7
>>>>
>>>> are the possibilities (ignoring any number over 30).
>>>>
>>>> Of which 3*7 is the largest.
>>>>
>>>> So, 1,252,398 divided by 21 = 59,638
>>>>
>>>>
>>>> Is that the sort of thing you are looking for?
>>>>
>>>>
>>>
>>> Yes, that looks exactly what like what I'm looking for.  I'm going to try
>>> and wake up the algebra side of my brain that hasn't been used in years
>>> and
>>> see if I can digest all this.
>>>
>>> For the 2, 3, and 7, that is based solely on the last number being
>>> divisible
>>> by a prime number?
>>>
>>> Joao, Jason, thanks for the code.
>>>
>>> --
>>> -Dan Joseph
>>>
>>> www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month.  Promo
>>> Code "NEWTHINGS" for 10% off initial order
>>>
>>> http://www.facebook.com/canishosting
>>> http://www.facebook.com/originalpoetry
>>>
>>
>> This seems to be working ...
>>
>> <?php
>> function findBestFactors($Value, $GroupSize, array &$Factors = null)
>>       {
>>       $Factors = array();
>>       foreach(range(1, ceil(sqrt($Value))) as $Factor)
>>               {
>>               if (0 == ($Value % $Factor))
>>                       {
>>                       if ($Factor <= $GroupSize)
>>                               {
>>                               $Factors[] = $Factor;
>>                               }
>>                       if ($Factor != ($OtherFactor = ($Value / $Factor)) && 
>> $OtherFactor
>> <= $GroupSize)
>>                               {
>>                               $Factors[] = $OtherFactor;
>>                               }
>>                       }
>>
>>               if ($Factor >= $GroupSize)
>>                       {
>>                       break;
>>                       }
>>               }
>>
>>       rsort($Factors);
>>
>>       return reset($Factors);
>>       }
>>
>> echo findBestFactors($argv[1], $argv[2], $Factors), PHP_EOL;
>> ?>
>>
>>
>> factors 1252398988 5000
>>
>> outputs  ...
>>
>> 4882
>>
>> and 21 for your value 1252398
>>
>> --
>> -----
>> 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
>>
>>
>

Thank you. It was a quick knock up, so could probably be optimized a
little more.

It will also not work beyond PHP_MAX_INT, unless the code is converted
to use the BCMath or GMP extension.

-- 
-----
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

--- End Message ---
--- Begin Message ---
On 22 April 2010 17:07, Dan Joseph <dmjos...@gmail.com> wrote:
> Howdy,
>
> This is a math question, but I'm doing the code in PHP, and have expunged
> all resources... hoping someone can guide me here.  For some reason, I can't
> figure this out.
>
> I want to take a group of items, and divide them into equal groups based on
> a max per group.  Example.
>
> 1,252,398 -- divide into equal groups with only 30 items per group max.
>
> Can anyone guide me towards an algorithm or formula name to solve this?  PHP
> code or Math stuff is fine.  Either way...
>
> Thanks...
>

What is wrong with 626,299 groups of 2 items each (done in my head, so
I might be off a little)?

-- 
Dotan Cohen

http://bido.com
http://what-is-what.com

--- End Message ---
--- Begin Message ---
On 23 April 2010 13:33, Dotan Cohen <dotanco...@gmail.com> wrote:
> What is wrong with 626,299 groups of 2 items each (done in my head, so
> I might be off a little)?

2, 3, 6, 7, 14 and 21 are all valid.


-- 
-----
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

--- End Message ---
--- Begin Message ---
I know the subject line might sound a bit like an oxymoron, but bear
with me!

What I'd like to have is a property of an object that behaves like a
public variable when it comes to reading, but like a protected one when
it comes to writing, as it would make my code a lot easier to read.

I know about the __get($var) method to magically provide this behaviour,
but from all I've read it can be pretty slow compared to a regular
public variable. I've seen a thread on the dev lists where someone
requested it, but can't find anything in the manual.

Does anyone know if this is available in a later version of PHP, or if
it's implementation is penned for some time in the future?

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



--- End Message ---
--- Begin Message ---
On 23 April 2010 10:55, Ashley Sheridan <a...@ashleysheridan.co.uk> wrote:
> I know the subject line might sound a bit like an oxymoron, but bear
> with me!
>
> What I'd like to have is a property of an object that behaves like a
> public variable when it comes to reading, but like a protected one when
> it comes to writing, as it would make my code a lot easier to read.
>
> I know about the __get($var) method to magically provide this behaviour,
> but from all I've read it can be pretty slow compared to a regular
> public variable. I've seen a thread on the dev lists where someone
> requested it, but can't find anything in the manual.
>
> Does anyone know if this is available in a later version of PHP, or if
> it's implementation is penned for some time in the future?
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>

What you are asking for is commonly known as accessibility. This has
been discussed on the list and is something I think would be a great
feature.

http://wiki.php.net/rfc/propertygetsetsyntax is an incomplete RFC (it
says it is incomplete at the top).

The last update was 2010/01/08 22:11, so a few months old.

Hopefully, some of the clever brains here can get to grips with it and
come to some consensus.


Whilst you can easily code __get()/__set() or getVar()/setVar()
methods to deal with it, with the later ones being significantly
easier to docblock, there is no easy way to document the property,
only the methods to set or get the property.


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

--- End Message ---
--- Begin Message ---
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.


--- End Message ---
--- Begin Message ---
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?

The Zend study guide might be a place to start - not for free thought,
so there may be better options (it's also directed at getting Zend
certified, so it's covering the stuff you need to know for that, not
connected things).

Regards
Peter

-- 
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
</hype>

--- End Message ---
--- Begin Message ---
On Fri, 2010-04-23 at 07:15 -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?
> 
> -- 
> Blessings,
> David M.
> 
> 


I started the way I guess most people did: from a basic book which broke
things up as it saw best. Obviously some books are better than others; I
won't mention any here as there are quite a few threads about good PHP
books.

>From there, I just looked into what I thought I needed to know as I came
across it. It's a bit haphazard, but it did the trick.

Mostly though, I think if you find a good book, that should break things
down well enough that anyone can pick it up and follow along. You don't
have to follow a book linearly though, I found myself often focusing in
more depth into something a book only mentioned briefly because it
either sounded interesting or I needed to know more for a project.

Bit of a ramble there, but maybe it'll help?

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



--- End Message ---
--- Begin Message ---
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.

Michiel

--- End Message ---
--- Begin Message ---
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?

My way of learning a new language is to decide on a small project to code and then learn just that i need to do for that exact feature i implement. That works best if you already has some knowledge in computer programming. And when i have grasped sufficiently i can dig into texts on the net for deeper understanding of the language.




--- End Message ---
--- Begin Message ---
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.

Paul

-- 
Paul M. Foster

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

I just figured, that the Browsers on my system do interpret &#039;
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&quot;
foo&#039;);alert(document.cookie);alert(&#039;');">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

--- End Message ---

Reply via email to