473,385 Members | 1,429 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Check a varible for a value

My skills are basic at best, but I can normally edit existing codes to suite my needs and someday hope to be good at it (any good coaches out there?)...

Any way, I am working on this piece of code that pulls in all the echos from a language include. Works fine but it generates dozens of "undefined variable" warnings each time it goes to the language file for another piece of text.

For instance, the language file contains:
Expand|Select|Wrap|Line Numbers
  1. $l_admin18 = "The webpage <b>$file</b> has been successfully edited!!!";
  2.  
My admin.php includes the language file and several lines down calls $l_admin18 but the $file variable is undefined within the language file but IS defined in the admin.php so it works fine, but I get the undefined notice.

Am I making sense?

My thoughts are to write a snippet that checks for a value, if none exist, a value is assigned. Is this the best way to go or is some "null" function better? or maybe just add the "@" to ALL the lines involved?

thanks in advanced and you'll probably see me on this forum ALOT... :)
Sep 21 '07 #1
3 1636
bergy
89
It sounds like maybe PHP is configured to display warnings when most web servers don't do warnings, only errors. An option maybe to add [PHP]global $file;[/PHP] at the top of the language file (and possibly in your admin.php file) so it uses the $file defined in admin.php. I'm not sure I fully understand exactly what's happening with the script you're talking about... maybe some more code directly from your file would make it clear.
Sep 21 '07 #2
Well, I did add:
Expand|Select|Wrap|Line Numbers
  1. error_reporting (E_ALL ^ E_NOTICE);
  2.  
To the beginning of the main "index.php" file which suppressed all the notices and the script works fine, but I read somewhere that you really should clean the code up so those messages don't show up - that is what I am trying to do.

the language file is just a list of variable declarations
Expand|Select|Wrap|Line Numbers
  1. $I_head1 = "text of some sort"
  2. $I_head2 = "some text"
  3. $I_head3 = "more text"
  4. $I_head4 = "and even more"
  5. etc...
  6.  
it is all the messages that get printed on screen and there are different version based on different languages.

the problem comes from when there is a variable called in the language code that has not been defined

$I_head2 = "the file named $file is big"

the $file variable is declared somewhere else, so when the language file is included, I get the "undefined" warning for each occurrence of the $file variable in the language php file.

Is there some code like "check variable if empty, ignore"?
Expand|Select|Wrap|Line Numbers
  1. if ( ! empty($file) (???)
Sep 21 '07 #3
pbmods
5,821 Expert 4TB
Heya, gr8graphix.

Please use CODE tags when posting source code:

[CODE=php]
PHP code goes here.
[/CODE]
Sep 21 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: The8thSense | last post by:
how to declare static varible and static method inside a class ? i try "public static ABC as integer = 10" and it said my declaration is invalid Thanks
4
by: Xero | last post by:
Hello. I am using vb.net. There are two forms in my project. One is 'base' and the other one is 'savecurrent'. There is a value stored in a textbox called 'qc_a' in 'base'. I want to inherit...
1
by: Peter | last post by:
Does anybody know how to convert a string to a varible? For example, I have defined 2 structures Structure SS dim Name as string dim ID as short end structure Structure TT
2
by: Aido82 | last post by:
Hi, this is probably a stupid question. Im trying to declare a varible to have the value of that in a text box when i declare the varible is there a way to give it the value in a text box...
3
by: ycinar | last post by:
I wonder if anyone could suggest on how to check if a varible is already freed or not in C++? Something like this: if(variablenane != free) { //do something } sure this syntax doesnt work......
1
by: anniefs | last post by:
hi help me i m so much stuck int he code and i have no time .... i used ASP VBscipt and javascript functions with MS database javascript function add records in MS DB by using ASP vbscript...
3
by: Sachin | last post by:
Hi Folks, I have one query in regarding const varible interpretaion by C/C++ compiler. How Compiler actually differentiate between normal stack varible and const varible during program execution?...
2
by: =?Utf-8?B?SHVzYW0=?= | last post by:
Hi EveryBody: I am using vb.net 2005 and the following code trying to create varible at runtime: For n=1 to 4 dim v+n.tostring(n) as double Next n the resone behaind using the previous...
3
by: kavitachawoor | last post by:
How to check popup window closed or with in that link button is clickedd or not.it mence-after displaying popup window if user close or click on link button with in the popup window the varible xyz...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.