Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

PHP 4.1.2 to 4.3.1 conversion problem with associative arrays

On one of my machines php 4.1.2, the following line works..

$installedModules[1] = array(module=>"Marketing", phpfile=>"cmps_marketing.php");

On another of my machines, 4.3.1, it doesn't work returning the error:

Notice: Use of undefined constant module - assumed 'module' in ..\index.php on line 44
Notice: Use of undefined constant phpfile - assumed 'phpfile' in ..\index.php on line 44


I have never had to do any typing on an associative array before.. what is the "correct" way to do this?
0
Palamedes
Asked:
Palamedes
  • 2
  • 2
1 Solution
 
VGRCommented:
of course 8-)

your 'module' and 'phpfile' have the syntax of PHP CONSTANTS (ie, no $ before the name -> variable, no quotes around -> string, and not a numerical value. Thus PHP asusmes it must be constants (define()) and you've not defined them.

This is 100% incorrect

If "it works" on an other installation, it must be because your reporting level did not include NOTICEs ;-)
(check php.ini for ERROR )

Change this into :
installedModules[1] = array('module'=>"Marketing", 'phpfile'=>"cmps_marketing.php");
0
 
PalamedesAuthor Commented:
That did the trick..

Thanks bud..  I even have a book that doesn't show putting single quotes around it..

I understand of course now why they are necessary.. It seems like typing wasn't as strong several versions ago..

Cheers.
0
 
VGRCommented:
just by curiosity : are you Greek ?
0
 
PalamedesAuthor Commented:
No.. but Palamedes was.. =)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now