POV-Ray : Newsgroups : povray.off-topic : Lamp me one Server Time
11 Oct 2024 01:23:57 EDT (-0400)
  Lamp me one (Message 17 to 26 of 26)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Invisible
Subject: Re: Lamp me one
Date: 6 Feb 2008 06:52:41
Message: <47a99f89$1@news.povray.org>
Invisible wrote:
> I just learned PHP. I feel unclean...

Ooo... POST data has all single-quote characters escaped by prefixing 
with a backslash, and PHP doesn't unescape them before giving the string 
back to you. That's a nice feature.

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Invisible
Subject: Re: Lamp me one
Date: 6 Feb 2008 07:05:51
Message: <47a9a29f$1@news.povray.org>
Nicolas Alvarez wrote:

> http://www.odi.ch/prog/design/php/index.php

"Uhm.. err.. I have never thought about this you may anser now. And that 
is exactly the point! Any unwary programmer will write codde like the 
line above and introduce severe security and stability problems in his 
code."

Irony, much? You're talking about unwary programmers and you apparently 
haven't spent much effort proof-reading what you just typed. ;-)


"No major other language requires you to redeclare global variables 
inside a function..."

Apparently Tcl isn't "major". ;-) It has precisely the same irritating 
feature.


"I am writing this guide to provide useful ways how to best structure 
your code."

Not your sentences, then?

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Darren New
Subject: Re: Lamp me one
Date: 6 Feb 2008 22:46:33
Message: <47aa7f19$1@news.povray.org>
Invisible wrote:
>> Don't do that on a real project. Use actual data-like templates. The 
>> problem is that the person writing the code isn't the person who 
>> decides what goes in the HTML.
> 
> Hmm. That sounds like an interesting problem to attempt to solve...

Meh. I use a templating thing.  I have a call to which you pass a 
template name, a style, an array of name->value pairs, and an array of 
name->function mappings.

The template name and style maps (eventually) to a file, with stuff like

<p>Welcome, <{name}>!</p>
<p><red><{{errormessage}}>></red></p>

Lines with <{{stuff}}> where there's no "stuff" key in the name->value 
array disappear completely. The rest get substituted. If the name has a 
"*" on the end, it doesn't get HTML-escaped, so you can pass raw HTML 
from the code. The name->function lets you do things like "display 
values greater than five minutes in red" or "NULL turns into 'N/A'"

On top of that, I built one that takes a head, row, and foot template, 
as well as a record resource (as returned by mysql_query()) and 
generates the whole page.



-- 
   Darren New / San Diego, CA, USA (PST)
     On what day did God create the body thetans?


Post a reply to this message

From: Darren New
Subject: Re: Lamp me one
Date: 6 Feb 2008 22:48:43
Message: <47aa7f9b$1@news.povray.org>
Invisible wrote:
> Apparently Tcl isn't "major". ;-) It has precisely the same irritating 
> feature.

It's not irritating, it's modular!  ;-)

Seriously, if you don't declare variables first, there really isn't a 
particularly good way of creating a global from inside a procedure, is 
there?

-- 
   Darren New / San Diego, CA, USA (PST)
     On what day did God create the body thetans?


Post a reply to this message

From: Nicolas Alvarez
Subject: Re: Lamp me one
Date: 6 Feb 2008 23:20:06
Message: <47aa86f6$1@news.povray.org>

> Invisible wrote:
>> Apparently Tcl isn't "major". ;-) It has precisely the same irritating 
>> feature.
> 
> It's not irritating, it's modular!  ;-)
> 
> Seriously, if you don't declare variables first, there really isn't a 
> particularly good way of creating a global from inside a procedure, is 
> there?
> 

$GLOBALS['varname'] = "stuff";

(no, I'm not being serious)


Post a reply to this message

From: Invisible
Subject: Re: Lamp me one
Date: 7 Feb 2008 04:17:47
Message: <47aaccbb$1@news.povray.org>
Darren New wrote:

> Seriously, if you don't declare variables first, there really isn't a 
> particularly good way of creating a global from inside a procedure, is 
> there?

Yeah there is: Declare variables first. :-P

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Darren New
Subject: Re: Lamp me one
Date: 7 Feb 2008 12:09:26
Message: <47ab3b46$1@news.povray.org>
Invisible wrote:
> Darren New wrote:
> 
>> Seriously, if you don't declare variables first, there really isn't a 
>> particularly good way of creating a global from inside a procedure, is 
>> there?
> 
> Yeah there is: Declare variables first. :-P

Sure. That's what [global] gets you.

Anyway, [global] is a special case of [upvar] and just basically has 
default arguments. Complaining you have to use [global] in Tcl is silly.

PHP has no [upvar], and PHP has "superglobals" which you don't have to 
redeclare inside procedures, so it's just a mess.

-- 
   Darren New / San Diego, CA, USA (PST)
     On what day did God create the body thetans?


Post a reply to this message

From: Joel Yliluoma
Subject: Re: Lamp me one
Date: 13 Feb 2008 03:06:55
Message: <slrnfr598v.6l7.bisqwit@bisqwit.iki.fi>
On 5 Feb 2008 10:36:30 -0500, Warp wrote:
> echo
>  'hello ' .
>  $user .
>  ", how are you?\n";

Or rather:

echo
  'hello ',
  $user,
  ", how are you?\n";

Or in this case:
  echo "Hello, $user, how are you?\n";

Interesting article touching the issue:
http://blog.libssh2.org/index.php?/archives/28-How-long-is-a-piece-of-string.html

-- 
Joel Yliluoma - http://iki.fi/bisqwit/


Post a reply to this message

From: Joel Yliluoma
Subject: Re: Lamp me one
Date: 13 Feb 2008 03:34:40
Message: <slrnfr5at0.6l7.bisqwit@bisqwit.iki.fi>
On Tue, 05 Feb 2008 13:51:33 -0200, Nicolas Alvarez wrote:
> Yes, and you can also pass multiple arguments to 'echo' (ie. what Warp 
> said, but with a comma instead of the concat operator). It's probably a 
> millisecond faster to do it that way too.
>
> http://blog.libssh2.org/index.php?/archives/28-How-long-is-a-piece-of-string.html

Oh, already posted. :o

-- 
Joel Yliluoma - http://iki.fi/bisqwit/


Post a reply to this message

From: Joel Yliluoma
Subject: Re: Lamp me one
Date: 13 Feb 2008 03:49:52
Message: <slrnfr5bpg.6l7.bisqwit@bisqwit.iki.fi>
On Wed, 06 Feb 2008 11:52:41 +0000, Invisible wrote:
> Invisible wrote:
>> I just learned PHP. I feel unclean...
>
> Ooo... POST data has all single-quote characters escaped by prefixing 
> with a backslash, and PHP doesn't unescape them before giving the string 
> back to you. That's a nice feature.

\"Magic quotes\". Extremely annoying. Disable at sight.

-- 
Joel Yliluoma - http://iki.fi/bisqwit/


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.