php-general Digest 16 Apr 2007 05:31:59 -0000 Issue 4737
Topics (messages 252969 through 252983):
Re: isset
252969 by: Larry Garfield
252970 by: Buesching, Logan J
simple form web site up date
252971 by: Joker7
252979 by: Wolf
252981 by: Børge Holen
Appending into associative arrays
252972 by: Otto Wyss
252974 by: Zoltán Németh
252976 by: Zoltán Németh
252977 by: Alister Bulman
252978 by: Robert Cummings
252980 by: Alister Bulman
Re: Json.php
252973 by: Otto Wyss
252975 by: Otto Wyss
Re: free allocated memory: HOW ?
252982 by: Chris
auto page generation
252983 by: Jeremy Adams
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
On Sunday 15 April 2007 12:07 pm, [EMAIL PROTECTED] wrote:
> > of course it's your call whether you write/run code that spits out
> > E_NOTICEs all over the place due to usage of uninitialized vars.
>
> not quite sure. if $_GET['var'] doesn't exists it's DEFINITLY not equal to
> 'foo', right?
>
> how I understand:
> clause one: isset($_GET['var'])
> clause two: ($_GET['var'] == 'foo')
> if clause two is true, clause one MUST be true.
> if clause one is true, clause two could be true or false.
>
> means, if I look for solutions where ($_GET['var'] == 'foo') they wil
> lautomaticaly cover isset($_GET['var']) part.
> if ($_GET['var'] != 'foo') I erally do not care isset($_GET['var']) or
> !isset($_GET['var']).
>
> or I'm missing something here?
>
> I have E_NOTICE turned off. :)
And right there is your first mistake. The only time to not have E_NOTICE on
is when you're using legacy code that isn't E_NOTICE compliant and you don't
have the time to upgrade it to be compliant. Developing without E_NOTICE
means you're telling the computer "it's OK, let me just randomly guess where
this bug or security hole or random typo is". *Bad* idea.
*Always* develop in the tightest, most restricted, most nit-picky setting you
can get, regardless of the language.
If you want your syntax to be a bit simpler, I frequently use helper functions
along these lines:
function http_get_int($var, $default=0) {
return isset($_GET[$var]) ? (int) $_GET[$var] : $default;
}
if (http_get_int('var') ==5) {
// Do stuff
}
Clean to read, easy defaults, (reasonably) type-safe, and E_NOTICE friendly.
--
Larry Garfield AIM: LOLG42
[EMAIL PROTECTED] ICQ: 6817012
"If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the possession
of every one, and the receiver cannot dispossess himself of it." -- Thomas
Jefferson
--- End Message ---
--- Begin Message ---
> how I understand:
> clause one: isset($_GET['var'])
> clause two: ($_GET['var'] == 'foo')
> if clause two is true, clause one MUST be true.
> if clause one is true, clause two could be true or false.
>
> means, if I look for solutions where ($_GET['var'] == 'foo') they wil
> lautomaticaly cover isset($_GET['var']) part.
> if ($_GET['var'] != 'foo') I erally do not care isset($_GET['var']) or
> !isset($_GET['var']).
If you are looking for
isset($_GET['var'])
to return true if the value exists, but may be null, you can always use
if (isset($_GET['var']) || is_null($_GET['var]))
Albeit, I'm unsure if this will generate a warning if $_GET['var']
doesn't exist for the is_null() call. And in this case, I believe it
would be appropriate to ignore that one warning.
-Logan
-----Original Message-----
From: Larry Garfield [mailto:[EMAIL PROTECTED]
Sent: Sunday, April 15, 2007 1:17 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] isset
On Sunday 15 April 2007 12:07 pm, [EMAIL PROTECTED] wrote:
> > of course it's your call whether you write/run code that spits out
> > E_NOTICEs all over the place due to usage of uninitialized vars.
>
> not quite sure. if $_GET['var'] doesn't exists it's DEFINITLY not
equal to
> 'foo', right?
>
>
> or I'm missing something here?
>
> I have E_NOTICE turned off. :)
And right there is your first mistake. The only time to not have
E_NOTICE on
is when you're using legacy code that isn't E_NOTICE compliant and you
don't
have the time to upgrade it to be compliant. Developing without
E_NOTICE
means you're telling the computer "it's OK, let me just randomly guess
where
this bug or security hole or random typo is". *Bad* idea.
*Always* develop in the tightest, most restricted, most nit-picky
setting you
can get, regardless of the language.
If you want your syntax to be a bit simpler, I frequently use helper
functions
along these lines:
function http_get_int($var, $default=0) {
return isset($_GET[$var]) ? (int) $_GET[$var] : $default;
}
if (http_get_int('var') ==5) {
// Do stuff
}
Clean to read, easy defaults, (reasonably) type-safe, and E_NOTICE
friendly.
--
Larry Garfield AIM: LOLG42
[EMAIL PROTECTED] ICQ: 6817012
"If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an
idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the
possession
of every one, and the receiver cannot dispossess himself of it." --
Thomas
Jefferson
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
I have said I would host a couple of friends CV's as a web page,here's the
situation I'd like to set it up so that it can updated it via a simple
form.I've googled the subject a fair bit and all I can come up with is big
full solutions when I only need a simple form and say a flat file system.Any
one have an idea or better still know of a pre-made form ect.
Cheers
Chris
--
Cheap As Chips Broadband http://yeah.kick-butt.co.uk
Superb hosting & domain name deals http://host.kick-butt.co.uk
--- End Message ---
--- Begin Message ---
I cheat for some of mine. I just write what I want/need to a MySQL with
form inputs and then the page just queries the database. takes it 0
time to do it that way, and in case there is something screwed up
date-wise, they can go in and fix it without too much hassle.
Wolf
Joker7 wrote:
I have said I would host a couple of friends CV's as a web page,here's the
situation I'd like to set it up so that it can updated it via a simple
form.I've googled the subject a fair bit and all I can come up with is big
full solutions when I only need a simple form and say a flat file system.Any
one have an idea or better still know of a pre-made form ect.
Cheers
Chris
--- End Message ---
--- Begin Message ---
On Sunday 15 April 2007 20:56, Joker7 wrote:
> I have said I would host a couple of friends CV's as a web page,here's the
> situation I'd like to set it up so that it can updated it via a simple
> form.I've googled the subject a fair bit and all I can come up with is big
> full solutions when I only need a simple form and say a flat file
> system.Any one have an idea or better still know of a pre-made form ect.
<form>
<textarea></textarea>
<input type=submit>
</form>
and choose whatever you have access and feel comfortable to, to use as
storage. This allows you to use html code to style, and the result is shown
on the frontend.
>
> Cheers
> Chris
>
> --
> Cheap As Chips Broadband http://yeah.kick-butt.co.uk
> Superb hosting & domain name deals http://host.kick-butt.co.uk
--
---
Børge
http://www.arivene.net
---
--- End Message ---
--- Begin Message ---
I want to sort directories according there modification time and thought
accociative arrays would be perfect. But when I add an element like
$dirs = array (filemtime($d) => $d)
the previous ones are lost. I tried array_push but that doesn't seems to
work, at least I always get syntax errors. Next try was
array_merge(array (...)). So what next?
O. Wyss
--- End Message ---
--- Begin Message ---
2007. 04. 15, vasárnap keltezéssel 21.20-kor Otto Wyss ezt írta:
> I want to sort directories according there modification time and thought
> accociative arrays would be perfect. But when I add an element like
>
> $dirs = array (filemtime($d) => $d)
why not simply
$dirs[] = array (filemtime($d) => $d);
greets
Zoltán Németh
>
> the previous ones are lost. I tried array_push but that doesn't seems to
> work, at least I always get syntax errors. Next try was
> array_merge(array (...)). So what next?
>
> O. Wyss
>
--- End Message ---
--- Begin Message ---
2007. 04. 15, vasárnap keltezéssel 21.20-kor Otto Wyss ezt írta:
> I want to sort directories according there modification time and thought
> accociative arrays would be perfect. But when I add an element like
>
> $dirs = array (filemtime($d) => $d)
(sorry the previous one is incorrect, I misunderstood what you
wanted...)
so:
$dirs[filemtime($d)] = $d;
greets
Zoltán Németh
>
> the previous ones are lost. I tried array_push but that doesn't seems to
> work, at least I always get syntax errors. Next try was
> array_merge(array (...)). So what next?
>
> O. Wyss
>
--- End Message ---
--- Begin Message ---
On 15/04/07, Zoltán Németh <[EMAIL PROTECTED]> wrote:
2007. 04. 15, vasárnap keltezéssel 21.20-kor Otto Wyss ezt írta:
> I want to sort directories according there modification time and thought
> accociative arrays would be perfect. But when I add an element like
>
> $dirs = array (filemtime($d) => $d)
(sorry the previous one is incorrect, I misunderstood what you
wanted...)
so:
$dirs[filemtime($d)] = $d;
Better, I think, to put the unique thing - the name, as the index.
Two directories may have the same modification time.
$dirs[$d] = filemtime($d);
Alister
--- End Message ---
--- Begin Message ---
On Sun, 2007-04-15 at 20:36 +0100, Alister Bulman wrote:
> On 15/04/07, Zoltán Németh <[EMAIL PROTECTED]> wrote:
> > 2007. 04. 15, vasárnap keltezéssel 21.20-kor Otto Wyss ezt írta:
> > > I want to sort directories according there modification time and thought
> > > accociative arrays would be perfect. But when I add an element like
> > >
> > > $dirs = array (filemtime($d) => $d)
> > (sorry the previous one is incorrect, I misunderstood what you
> > wanted...)
> > so:
> > $dirs[filemtime($d)] = $d;
>
> Better, I think, to put the unique thing - the name, as the index.
> Two directories may have the same modification time.
>
> $dirs[$d] = filemtime($d);
Has he even retrieved the directories in sorted order by modification
time? If not he still needs to sort.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--- End Message ---
--- Begin Message ---
On 15/04/07, Robert Cummings <[EMAIL PROTECTED]> wrote:
On Sun, 2007-04-15 at 20:36 +0100, Alister Bulman wrote:
> On 15/04/07, Zoltán Németh <[EMAIL PROTECTED]> wrote:
> > 2007. 04. 15, vasárnap keltezéssel 21.20-kor Otto Wyss ezt írta:
> > > I want to sort directories according there modification time and thought
> > > accociative arrays would be perfect. But when I add an element like
> Better, I think, to put the unique thing - the name, as the index.
> Two directories may have the same modification time.
> $dirs[$d] = filemtime($d);
Has he even retrieved the directories in sorted order by modification
time? If not he still needs to sort.
Then he'll need an asort($dirs); They would not have come in any
particular order, so you have to sort them for whatever you need
anyway.
Alister
--- End Message ---
--- Begin Message ---
Tijnema ! wrote:
*ROFLMFAO*...Did you actually try google for json.php?
Second result:
http://mike.teczno.com/JSON/JSON.phps
This doesn't have a json_encode but needs a $json object which then
could be used as $json->encode(...). Thanks anyway.
O. Wyss
--- End Message ---
--- Begin Message ---
Satyam wrote:
www.json.org lists all json resources in any language you care to think of.
I must admit I haven't checked each reference but the ones I have have
only packages to install and not a PHP source. Maybe I wasn't clear when
asking.
O. Wyss
--- End Message ---
--- Begin Message ---
Richard Lynch wrote:
On Fri, April 13, 2007 12:54 am, Arthur Erdös wrote:
It can if you're trying to process a borked image...
I've had imagecreatefromjpeg() eat memory up to almost 50x the size
of
the image before finally deciding it can't handle it and crapping
out.
That was *after* running it through getimagesize() with no problem
at all.
okay - good point - but in this case the OP is reading in an html
template file,
just a string of 20.7Kb, what could go wrong there?
this is probably one issue... the template is an HTML template
containing images like <img src="http://www.brainguide.com/xxx"/>. How
does PHP handle this stuff? I suppose that it is just a string and the
image at the URL is not really read, or am I wrong?
The newsletter does not have any attachements.
Now you're not making any sense at all...
Either your newsletter has the images in it, or it doesn't.
Embedded images are different to images with a href. To embed images,
you need to read them in to memory and attach them (much the same as a
regular attachment). Referencing a href like that doesn't do anything,
it's just part of the string.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
I'm building a website right now that will be a database of attractions in
the Carolina and Virginia area.
The idea is that attraction owners can submit data to the database and the
database will automatically generate a page containing that information.
What I'm trying to figure out is how to generate the pages automatically and
have links to them added to the site. If someone could help me or point me
in the direction of a book or web page that covers this I would really
appreciate it.
--- End Message ---