473,503 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how while loop value prints outside loop

ditditsasa
17 New Member
Expand|Select|Wrap|Line Numbers
  1. while (false !== ($sfname = readdir($dh))) {
  2.   if (substr($sfname, 0, 1) == '.') continue;
  3.   if ($sfname == 'CVS'            ) continue;
  4.   $sitedir = "$OE_SITES_BASE/$sfname";
  5.   if (!is_dir($sitedir)               ) continue;
  6.   if (!is_file("$sitedir/sqlconf.php")) continue;
  7.   $siteslist[$sfname] = $sfname;
  8.     }    echo $sfname;//here not prints sfname value
the value not prints outside the loop. please help me
Apr 12 '12 #1
2 1985
dlite922
1,584 Recognized Expert Top Contributor
You can't print a variable in the scope of the while loop outside it's scope, outside the while loop.

Your code iterates through the while loop and prints the last value that was assigned to $sfname.
Apr 12 '12 #2
johny10151981
1,059 Top Contributor
@dilite922 I am confused about the information of while loop scope.
as far I know, while loop, if statement don’t have their own scope.

but about ditditsasa's problem, if the while condition does not satisfy in the first place in your print you won’t get anything.
Apr 13 '12 #3

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

Similar topics

1
1958
by: Gordon Williams | last post by:
Hi, I have been using this code for a number of weeks without problems. Now I am getting an exception after the program has run a short while. It has already passed through this function...
4
1593
by: Byte | last post by:
The following code will not work for me: x = 1 while x == 1: print 'hello' x = input('What is x now?: ') while x == 2: print 'hello again'
9
9295
by: wreed | last post by:
I have a for loop seen below.... var the_form = document.getElementById(formName); for(var i=0; i<the_form.length; i++) { var temp = the_form.elements.type; if (temp == "radio") { for (x =...
4
2852
by: Uday Bidkar | last post by:
I am trying to register my interface with IConnectionPoint of outlook reminders to capture some Outlook Reminder events and having some issues. Here goes the pseudo code int APIENTRY...
4
1548
by: JuG | last post by:
Hi, Is there any way to display a value in the NumericUpDown control that is bigger than Max or smaller than Min? Especially when I am just creating the control, not when the user changes it...
16
2166
by: littlegreen | last post by:
Hi all, I would like to know how to assign and get the form value when I using it in a loop. I cannot get all the input that I inserted in 'Desc' part and it is from this site. May I know to get...
2
2390
by: virtualweb | last post by:
Hello: I got stuck again.... In my Hotel Reservation script all reservations are saved in a flat file which name is the room number. (example: Data/room1-101.dat). Reservations are saved in...
2
1327
by: dotnetnovice | last post by:
Hi everybody! I have a problem and need help Here is the code. public void GetAllValues(Person V) { SqlConnection conn = new SqlConnection(ConnectionString); ...
5
5626
by: dave816 | last post by:
Sorry for the Excel question in an Access forum...................I don't see an Excel forum and there's probably a reason for that but figured I'd give this a shot anyway. Again sorry, delete if...
8
5872
by: Shilpa Sethi | last post by:
I wanted to know which one is better in performance between a for loop and a while loop in terms of: 1. memory requirement 2. execution speed Also wanted to know since recursion functions are...
0
7201
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7083
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7278
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5011
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1510
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
379
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.