Jump to content

Recommended Posts

Hi all.

I've just starting messing around with PHP and MySQL and just have a quick question.

I'm playing around with a site that guy built for me a while ago and have set it up on my local machine. All seems to be going well so far but I am curious about one thing.

How come this:

[code]<? echo $_POST[fax] ?>[/code]

works remotely, but locally I have to use the following:

[code]<? echo $_POST['fax'] ?>[/code]

Without the apostrophe on the variable I get [b]Notice: Use of undefined constant fax - assumed 'fax' in..[/b]

Can anyone shed some light?

Many thanks :)

Link to comment
https://forums.phpfreaks.com/topic/28433-why-do-i-have-to-use-apostrophes-locally/
Share on other sites

Its because you are supposed to use apostrophes around associative arrays. Otherwise PHP thinks you're using a constant and thus you get a Notice message.

Also it is not a configuration setting within the php.ini!
Your remote site is doing the same thing as what it does locally, except it doesn't show the notice message. Most probably because your host has disabled the display_errors directive or has set error_reporting directive to ignore notices.

Also notices do not stop a script from running. Only error messages do.

However as I did say in my last post you [b]should[/b] put apostrophes around associative indices. The only time you don't put apostrophises is when you use numerical indices.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.