php-general Digest 18 Dec 2006 03:31:05 -0000 Issue 4520
Topics (messages 245924 through 245934):
Re: How php works?
245924 by: Robert Cummings
PHP problem with array keys / pointers
245925 by: julian haffegee
245926 by: Pintér Tibor
245927 by: Satyam
245928 by: Jochem Maas
245932 by: julian haffegee
245933 by: Robert Cummings
Re: problem loading phpinfo
245929 by: Casey Chu
Clearing POST variable on page refresh
245930 by: Beauford
245931 by: Stut
simplest way in php to get our content on another site / included javascript
question
245934 by: jonathan
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:
php-general@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
On Sun, 2006-12-17 at 14:41 +0000, Roman Neuhauser wrote:
> # [EMAIL PROTECTED] / 2006-12-16 09:52:18 -0500:
> > On Sat, 2006-12-16 at 15:59 +0000, Roman Neuhauser wrote:
> > > # [EMAIL PROTECTED] / 2006-12-16 07:24:49 -0500:
> > > > On Sat, 2006-12-16 at 19:58 +0800, Kai Xiang wrote:
> > > > > On 12/16/06, Richard Lynch <[EMAIL PROTECTED]> wrote:
> > > > > > (*)
> > > > > > Actually, if somebody wants to embed the ZE inside of something
> > > > > > other
> > > > > > than PHP, then I think Zend expects to get paid for that.
> > > >
> > > > I don't think so... the PHP and Zend licenses are quite liberal with
> > > > very few restrictions. Namely that you don't call your software php or
> > > > use php in the name (something many packages seem to ignore (either that
> > > > or they got permission)). The Zend license is practically a clone of the
> > > > PHP license with a search and replace for PHP to Zend :) There's nothing
> > > > that says you have to pay to embed it in your own software. That said,
> > > > if you make a product that uses either the PHP or Zend engine and makes
> > > > oodles of money, I think you should feel somewhat morally obliged to
> > > > give back in some way.
> > >
> > > Sorry if I take this OT, but when I publish my work under the MIT license,
> > > I mean it. Anything else would be hypocrisy. OSS is not beggarware.
> >
> > I'm not sure I understand the point you are making :/
>
> That the license states everything he needs to feel obliged to.
Ah well, I was stating my opinion denoted by "I think". Sorry to have
wrinkled your panties.
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 ---
Hi all,
I've a problem thats been bothering me for a week now
I have an array $animals
keys and values like this
1 => cat
2 => dog
3 => mouse
4 => horse
I want to be able to access them using either a key or a pointer, however
the key/pointer will be a variable
without variables, if I want dog, I can either use $animals[1] or
$animals['2']
but with a variable , eg. $x = 2
$animals[$x] will always give me 'mouse'
what syntax do I need to use for $animals[$x] to give me 'dog' when $x=2 ?
I've tried all manner of apostrophes and escaped apostrophes, but no luck.
Can anyone help me
Thanks for your time!
jules
--- End Message ---
--- Begin Message ---
1 => cat
2 => dog
3 => mouse
4 => horse
iwfm with array(1=>'cat',2=>'dog',3=>'mouse',4=>'horse'):
output:
Array
(
[1] => cat
[2] => dog
[3] => mouse
[4] => horse
)
dog
source:
<?
$animals=array(1=>'cat',2=>'dog',3=>'mouse',4=>'horse');
print_r($animals);
$x=2;
echo $animals[$x]."\n";
?>
t
--- End Message ---
--- Begin Message ---
----- Original Message -----
From: "julian haffegee" <[EMAIL PROTECTED]>
To: <php-general@lists.php.net>
Sent: Sunday, December 17, 2006 7:31 PM
Subject: [PHP] PHP problem with array keys / pointers
Hi all,
I've a problem thats been bothering me for a week now
I have an array $animals
keys and values like this
1 => cat
2 => dog
3 => mouse
4 => horse
I want to be able to access them using either a key or a pointer, however
the key/pointer will be a variable
without variables, if I want dog, I can either use $animals[1] or
$animals['2']
but with a variable , eg. $x = 2
$animals[$x] will always give me 'mouse'
what syntax do I need to use for $animals[$x] to give me 'dog' when $x=2
?
I would think that you have string keys instead of integer ones. Perhaps
there is some whitespace in the variable using to set the key?
For example:
$array = array(' 2' => 'dog'); // there is a whitespace before the number 2
will set the element of ordinal number 0 and key ' 2' to 'dog'. To get
that value you would either ask for $array[0] or $array[' 2'].
Doing a print_r() or var_dump() on the array will let you know what the
actual contents of both the keys and values are.
Satyam
--- End Message ---
--- Begin Message ---
don't hijack an existing thread. (i.e.
don't reply to someone elses' post/reply if your
asking a new question.
you need to learn to use var_dump(), and if you look at
the line of code below you should have everything you need
to know about numeric array keys:
$a = array(2 => "foo"); $b = array("2" => "foo"); var_dump($a, $b, ($a === $b));
julian haffegee wrote:
> Hi all,
>
> I've a problem thats been bothering me for a week now
>
> I have an array $animals
>
> keys and values like this
>
> 1 => cat
> 2 => dog
> 3 => mouse
> 4 => horse
>
> I want to be able to access them using either a key or a pointer,
> however the key/pointer will be a variable
>
> without variables, if I want dog, I can either use $animals[1] or
> $animals['2']
>
> but with a variable , eg. $x = 2
> $animals[$x] will always give me 'mouse'
>
> what syntax do I need to use for $animals[$x] to give me 'dog' when $x=2 ?
>
> I've tried all manner of apostrophes and escaped apostrophes, but no
> luck. Can anyone help me
> Thanks for your time!
> jules
>
--- End Message ---
--- Begin Message ---
will set the element of ordinal number 0 and key ' 2' to 'dog'. To get
that value you would either ask for $array[0] or $array[' 2'].
thanks for all the comments so far, i'm not sure you are understanding what
I am asking for.
My problem is NOT knowing what is in the arrays, but how to access them.
My ordial number/key is a variable, and I need to sometimes use it as a key,
and sometimes as an ordial
so I need 2 ways of writing $array[$x],
one being equivalent to $array[0] - $x is treated as an integer
and one being equivalentt to $array['0'] - $x is treated as a string
so far I can only get it to work as an ordial number not a string. Any
attempt at apostrophes around $x brings up an error
Any ideas?
Jules
--- End Message ---
--- Begin Message ---
On Sun, 2006-12-17 at 23:19 +0000, julian haffegee wrote:
> > will set the element of ordinal number 0 and key ' 2' to 'dog'. To get
> > that value you would either ask for $array[0] or $array[' 2'].
>
>
> thanks for all the comments so far, i'm not sure you are understanding what
> I am asking for.
> My problem is NOT knowing what is in the arrays, but how to access them.
>
> My ordial number/key is a variable, and I need to sometimes use it as a key,
> and sometimes as an ordial
>
> so I need 2 ways of writing $array[$x],
>
> one being equivalent to $array[0] - $x is treated as an integer
> and one being equivalentt to $array['0'] - $x is treated as a string
$array['0'] and $array[0] are identical in PHP. The string '0' will be
automatically juggled to an integer when used as an index. You CANNOT
differentiate even if you want.
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 ---
You probably didn't install PHP correctly.
On 12/16/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Please,
Could you tell me if this problem has been resolved:
I am using php-5.2X and has this problem, I also had this problem when I was
using php-5.1.X.
My Apache is httpd-2.2.3.
Here is the post from someone who is having the same problem.
####################
I config PHP4.0.6 for Apache 1.3.12 for Win32
: in apache configuation file:
ScriptAlias /php/ "C:/PHP/"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/php.exe"
then I test with phpinfo.php file in htdocs directory.
: phpinfo.php :
<?php phpinfo(); ?>
when I type: http://localhost/phpinfo.php, Browser should show me some
information table but It show me the original code.
<?php phpinfo(); ?>
[16 Nov 2001 5:17am UTC] [EMAIL PROTECTED]
Please ask support questions on the php-general@lists.php.net
mailinglist.
Not a bug > closing
#######################
Any help would be highly appriciated.
Thank You,
IT Consultant (UNIX, Oracle, Sybase, MSSQL,MYSQL,MCSA)
Chris Ok'Onkwo
[EMAIL PROTECTED]
Tel: 0041-79-656-0889
________________________________________________________________________
Check Out the new free AIM(R) Mail -- 2 GB of storage and industry-leading spam
and email virus protection.
--- End Message ---
--- Begin Message ---
Hi,
I have a page with a form on it which posts to itself. The problem is when
someone refreshes the page it enters the data into the DB again. How do I
clear these variables so that doesn't happen. I tried the unset function,
but no luck. I really don't want to use sessions or cookies as this is just
a simple little page, but still, it has to work right.
Thanks
--- End Message ---
--- Begin Message ---
Beauford wrote:
I have a page with a form on it which posts to itself. The problem is when
someone refreshes the page it enters the data into the DB again. How do I
clear these variables so that doesn't happen. I tried the unset function,
but no luck. I really don't want to use sessions or cookies as this is just
a simple little page, but still, it has to work right.
Use the header function (http://php.net/header) to redirect to the same
page. The POST vars are coming from the client, so you can't get rid of
them by unsetting them. By redirecting you are giving the browser a new
page which is then what will be retrieved if the user refreshes it,
rather than refreshing the POSTed request.
-Stut
--- End Message ---
--- Begin Message ---
I'm working on a project where we'd want partner sites to get our
content on the other web sites.
A key priority is that they won't have much technical sophistication
(probably no db experience or php experience).
Also, these would be third party sites so there would also be an
issue of requirements (differnet xsl processors,
no allow_url_fopen, etc...)
I tried looking at sites that get their content on other sites to see
how they do it:
the possible solutions seem to be:
1. rss / xml - this is "well known" but would have a pretty high
technical hurdles on the other sites. We could create
every walk through and code sample but I still think it would be too
involved. Only way out is either a xsl transformation (not
going to happen), custom parsing library in php (maybe) or writing to
db with associated libraries (too complex)
2. serialized php with custom library - this seems more feasible than
#1 in terms of requirements
3. php proxy and ajax call / json - i think this would be too complex
and would require too much manipulation of apache to handle
subdomains, etc.....
4. included javascript - kinda how digg handles syndication (see
http://www.digg.com/add-digg for example).
This would seem to be the lowest barrier to entry. The main concern
is preventing unauthorized bots from crawling. It would seem
our only option would be using the referer property but this could be
forged relatively easily.
5. SOAP - no way
6. REST - if meant to just mean xml, i see this as an extension of #1.
any thoughts or opinions would be appreciated.
-jt
--- End Message ---