473,394 Members | 2,160 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,394 software developers and data experts.

Curious situation

I set a few session variables in a.php where each of the session variables
is an array of the same size and call b,php. In b.php I get new arrays from
those session variables. I then echoed the contents of the arrays in a
loop. This works fine.

Now, I went to do a require_once where I put the decomposition of the
session variables into an include file and just included that file in b.php
instead of explicitly have those lines there in b.php. The result was the
set of php statements in the include file followed by the contents of the
arrays.

Why do the php code lines show up in the output?

An example of what I am talking about is shown below.

Shelly

First b.php:
------------
$num = $_SESSION['num'];
$var1 = $_SESSION['var1'];

for ($i=0; $i<$num; $i++) {
echo $var1[$i] . "<br>";
}
===============
Second b.php
---------------
require_once("decomp.inc");
for ($i=0; $i<$num; $i++) {
echo $var1[$i] . "<br>";
}

decomp.inc
-------------
$num = $_SESSION['num'];
$var1 = $_SESSION['var1'];
============================
First output:
-------------
value1
value2
=============================
Second output:
-----------------
$num = $_SESSION['num'];$var1 = $_SESSION['var1'];
value1
value2
===============================
Jul 17 '05 #1
3 1340
I noticed that Message-ID: <oq********************@comcast.com> from
Shelly contained the following:
Why do the php code lines show up in the output?


At a guess you haven't put <?php and ?> around the code in decomp.inc

When doing an include or a require you effectively drop out of php. So
what you really have is:

?>
$num = $_SESSION['num'];
$var1 = $_SESSION['var1'];
<?php

hence the code is simply treated as plain html

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2
\"Geoff Berrow" <bl******@ckdog.co.uk> wrote in message
news:8t********************************@4ax.com...
I noticed that Message-ID: <oq********************@comcast.com> from
Shelly contained the following:
Why do the php code lines show up in the output?


At a guess you haven't put <?php and ?> around the code in decomp.inc

When doing an include or a require you effectively drop out of php. So
what you really have is:

?>
$num = $_SESSION['num'];
$var1 = $_SESSION['var1'];
<?php

hence the code is simply treated as plain html


Makes sense. No, I didn't because I thought includes worked the way they do
in C, C++, Java, etc. Looking at the my other include for db stuff (that
was set up in Connections in Dreamweaver) it has the bracketing. What is
interesting is I use that code as:

<?php require_once("dbLoginStuff.php"); ?>

and the dbLoginStuff.php has

<?php stuff ?>

I didn't notice this before, but this would give

<?php <?php stuff ?> ?>

if it worked like other includes.

Thanks.

Shelly
Jul 17 '05 #3
That worked. Thanks.

Shelly

"Shelly" <sh************@asap-consult.com> wrote in message
news:UI********************@comcast.com...
\"Geoff Berrow" <bl******@ckdog.co.uk> wrote in message
news:8t********************************@4ax.com...
I noticed that Message-ID: <oq********************@comcast.com> from
Shelly contained the following:
Why do the php code lines show up in the output?


At a guess you haven't put <?php and ?> around the code in decomp.inc

When doing an include or a require you effectively drop out of php. So
what you really have is:

?>
$num = $_SESSION['num'];
$var1 = $_SESSION['var1'];
<?php

hence the code is simply treated as plain html


Makes sense. No, I didn't because I thought includes worked the way they
do in C, C++, Java, etc. Looking at the my other include for db stuff
(that was set up in Connections in Dreamweaver) it has the bracketing.
What is interesting is I use that code as:

<?php require_once("dbLoginStuff.php"); ?>

and the dbLoginStuff.php has

<?php stuff ?>

I didn't notice this before, but this would give

<?php <?php stuff ?> ?>

if it worked like other includes.

Thanks.

Shelly

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Randell D. | last post by:
Folks, A ng poster recently questioned their usage/creation of arrays and their correct syntax. I got the idea to performance test from a recent (excellent) PHP Tutorial article that was in Linux...
0
by: steve | last post by:
Hi, I am running phpmyadmin v2.5.6, and if I try to edit records, and some of those records have long text data (e.g. 1000 characters) in text fields, then edit shows a blank page. I managed to...
5
by: Stu | last post by:
When I have a form in view mode, the buttons at the bottom open several other forms, such as a contact list, and a "home" page. If I leave the cursor over the button for a second, the little...
40
by: Confused User | last post by:
I am curious what the origins of size_t are. I see that it is usually typedef'd to be the native integer size of a particular machine. I also see that routines like strncpy(char *t, const char *s,...
7
by: tshad | last post by:
I was curious if there is some reason why you don't need the "then" in the if test of VB.Net or is it just ASP.NET. I just noticed that I don't really need to explicitly put the word "then" as...
3
by: CoreyWhite | last post by:
I wrote a program that shows some incredibly curious probabilities. It is a simple game where you guess a number between 0 and 2 that the computer thinks up. What is origonal about this game is...
1
by: titch | last post by:
A curious problem I've encountered which can be seen with a simple piece of HTML: <div id="a" style="position: absolute; top:5px; left: 5px; width:100px; height:100px; border: 1px solid red;">...
8
by: Patrick Smith | last post by:
Hi All, I found this in a page I was looking at and am wondering what does the slash in the second width do? Is this valid css? This technique was used in several places in the style sheet....
6
by: =?Utf-8?B?TWljaGVsIFBvc3NldGggW01DUF0=?= | last post by:
Hello i just encountered a funny situation Dim i As Integer = 0 MsgBox(i = Nothing) and
11
by: Liz | last post by:
anyone have any idea why there have been (at least) 82 VS 2008 post-release messages here on the C# board but only 5 on the VB.NET board; are the VB crowd just not interested?? strikes me as a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.