PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > alt.php > I am stuck: Error on a line that begins with the word "const" !!
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
I am stuck: Error on a line that begins with the word "const" !!

Réponse
 
LinkBack Outils de la discussion
Vieux 08/12/2007, 00h58   #1
adam.timberlake@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut I am stuck: Error on a line that begins with the word "const" !!

Me again! I am trying to create a currency converter function for my
eCommerce that still pet treats. I am a little short on money recently
and so cannot afford a programmer. Can somebody tell me why my script
tells me that I have a syntax error on the "CONST" line. I am trying
to follow the article below.

Article: http://www.talkphp.com/showthread.php?t=1503

The error I get is:

Parse error: parse error, expecting `T_OLD_FUNCTION' or
`T_FUNCTION'...

My server is CentOS 4 or 5, I forget which, running PHP 4.1.0 with
MySQL 5, I think. The line that it shows me the error on is:

const OPT_FILE = 'talkphp_conversion_rates.json';

Please ! Also, somebody mentioned something about cross-posting on
newsgroups so that I can post to more than 1 group in case I do not
get a good answer in 1. Could somebody tell me how to do this with
Google Groups please!!

Thannk you.
  Réponse avec citation
Vieux 08/12/2007, 02h33   #2
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: I am stuck: Error on a line that begins with the word "const"!!

adam.timberlake@gmail.com wrote:
> Me again! I am trying to create a currency converter function for my
> eCommerce that still pet treats. I am a little short on money recently
> and so cannot afford a programmer. Can somebody tell me why my script
> tells me that I have a syntax error on the "CONST" line. I am trying
> to follow the article below.
>
> Article: http://www.talkphp.com/showthread.php?t=1503
>
> The error I get is:
>
> Parse error: parse error, expecting `T_OLD_FUNCTION' or
> `T_FUNCTION'...
>
> My server is CentOS 4 or 5, I forget which, running PHP 4.1.0 with
> MySQL 5, I think. The line that it shows me the error on is:
>
> const OPT_FILE = 'talkphp_conversion_rates.json';
>


'const' is not a valid PHP keyword. Maybe you want:

define('OPT_FILE', 'talkphp_conversation_rates.json');

But not having the rest of your code, it's hard to tell.


> Please ! Also, somebody mentioned something about cross-posting on
> newsgroups so that I can post to more than 1 group in case I do not
> get a good answer in 1. Could somebody tell me how to do this with
> Google Groups please!!
>


I have no idea how to do it through GG - get yourself a real newsreader.
Your ISP most probably has access to usenet. It's much better.

> Thannk you.
>



--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

  Réponse avec citation
Vieux 08/12/2007, 05h27   #3
J.O. Aho
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: I am stuck: Error on a line that begins with the word "const"!!

adam.timberlake@gmail.com wrote:

> My server is CentOS 4 or 5, I forget which,


cat /etc/issue
That should tell you a bit about which version you are using


> running PHP 4.1.0 with
> MySQL 5, I think. The line that it shows me the error on is:


This makes me believe it's NOT CentOS5.


> const OPT_FILE = 'talkphp_conversion_rates.json';
> Parse error: parse error, expecting `T_OLD_FUNCTION' or
> `T_FUNCTION'...


const can only be used in a class, so

<?PHP
const OPT_FILE = 'talkphp_conversion_rates.json';
?>

will genereate your error message

<?PHP
class something {
const OPT_FILE = 'talkphp_conversion_rates.json';
}
?>

This would be ok.

If you want to use a "constatn" outside a class, you have to use define as
Jerry suggested.


--

//Aho
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 04h10.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11109 seconds with 11 queries