Hi. Sorry for what is perhaps a neophyte question: is it possible to
pass a variable to a PHP script from inside another PHP piece of code?
For instance, the file test.php (which of course resides on a
webserver that supports PHP) is as such:
[some HTML code...]
<?php
echo("<i>the variable abc contains " . $_GET['abc'] . "</i>");
?>
[some more HTML code...]
and if I open this file directly i.e. by typing test.php?abc=88 8 in
the URL line of a web browser, I correctly get the message "the
variable abc contains 888" in italic, surrounded by the HTML content.
Now, let's say that I want to include all this content in another
file, index.php.
I tried to call it as such in index.php
[other HTML...]
<?php
include "test.php?abc=8 88";
?>
[yet other HTML...]
which is not the correct way as it gives the following error:
Warning: main(l/test.php?abc=88 8) [function.main]: failed to open
stream: No such file or directory in /home/www/index.php on line 52
Warning: main() [function.includ e]: Failed opening 'l/test.php?
abc=888' for inclusion (include_path=' .:/usr/share/php:/usr/share/
pear') in /home/www/index.php on line 52
How should I call the file?
Thanks in advance for any hint! 3 1844
The file is l/test.php of course.
On Sat, 27 Oct 2007 23:44:56 +0200, le************* **********@gmai l.com
<le************ ***********@gma il.comwrote:
Hi. Sorry for what is perhaps a neophyte question: is it possible to
pass a variable to a PHP script from inside another PHP piece of code?
For instance, the file test.php (which of course resides on a
webserver that supports PHP) is as such:
[some HTML code...]
<?php
echo("<i>the variable abc contains " . $_GET['abc'] . "</i>");
?>
[some more HTML code...]
and if I open this file directly i.e. by typing test.php?abc=88 8 in
the URL line of a web browser, I correctly get the message "the
variable abc contains 888" in italic, surrounded by the HTML content.
Now, let's say that I want to include all this content in another
file, index.php.
I tried to call it as such in index.php
[other HTML...]
<?php
include "test.php?abc=8 88";
?>
[yet other HTML...]
which is not the correct way as it gives the following error:
Warning: main(l/test.php?abc=88 8) [function.main]: failed to open
stream: No such file or directory in /home/www/index.php on line 52
Warning: main() [function.includ e]: Failed opening 'l/test.php?
abc=888' for inclusion (include_path=' .:/usr/share/php:/usr/share/
pear') in /home/www/index.php on line 52
How should I call the file?
Thanks in advance for any hint!
The $_GET array is available to all scipts, _provided_ you use the file
system to include the file, and not by http some newcomers seem to do. So:
URL:
test.php?foo=ba r
test.php:
<?php
$check = 'hello';
include './include.php';
?>
include.php
<?php
var_dump($_GET) ;
echo $check;
?>
... will correctly show the $_GET array and the $check variable.
--
Rik Wasmus
Thanks a lot for these very useful and quick answers! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jan Pieter Kunst |
last post by:
(apologies if this message is a duplicate -- my news server seems to
have problems)
Greetings,
When using PHP 4, this:
// ex. 1
class A {
function A(&$obj) {
|
by: Chris Lasher |
last post by:
Hello,
I would like to create a set of very similar regular expression. In
my initial thought, I'd hoped to create a regular expression with a
variable inside of it that I could simply pass a string into by
defining this variable elsewhere in my module/function/class where I
compile the regular expression, thus making for an easy substitution.
However, still after JFGI'ing, I still cannot find the syntax to place
a variable inside a...
|
by: frogman042 |
last post by:
My daughter is playing around trying to learn JavaScript and she wrote
a small program that prints out a message in increasing and decreasing
font size and color changes. She is using document write and it works
fine until she puts it into a function and then calls the function from
a button with onClick. This also seems to work OK, with the exception
that the page is cleared, and the curser changes (and stays) as an
hourglass.
In...
|
by: Daniel |
last post by:
Hi,
Does anyone know if it is possible to put an aspx page inside of another? OR
run an aspx page and capture the output as a string and then write this out
to a page....
So for example say you have a page that takes an id number as a query string
and displays different things based on that id number.
If you were able to loop through running the aspx pages with id=100, id=200,
|
by: Daz |
last post by:
Hi everyone. Sorry for the confusing subject, I couldn't think how best
to word it.
What I would like to know, is if there is an equivilant to this code,
in using JSON.
<script type="text/javascript">
function makeTable(number_of_rows) {
var table = document.createElement('table');
table.border = 1;
| |
by: pbmods |
last post by:
VARIABLE SCOPE IN JAVASCRIPT
LEVEL: BEGINNER/INTERMEDIATE (INTERMEDIATE STUFF IN )
PREREQS: VARIABLES
First off, what the heck is 'scope' (the kind that doesn't help kill the germs that cause bad breath)? Scope describes the context in which a variable can be used. For example, if a variable's scope is a certain function, then that variable can only be used in that function. If you were to try to access that variable anywhere else in...
|
by: IRC |
last post by:
hey, i am pretty new on javascript as well as PHP,
Hey, anyone can you help me, how to pass the javascript array value to
php page.........
i want to retrieve the values which are arrayed on "selectedValues"
from next page for php variable
this is my javascript code saved on "sendValue.js" file,
<script>
function updateRecordEntry(requestValue){
|
by: Bryan Parkoff |
last post by:
I write my large project in C++ source code. My C++ source code
contains approximate four thousand small functions. Most of them are
inline. I define variables and functions in the global scope. The global
variables and global functions are hidden to prevent from accessing by the
programmers. All global functions share global variables.
Only very few global functions are allowed to be reusability for the
programmers to use. Few...
|
by: raylopez99 |
last post by:
Keywords: scope resolution, passing classes between parent and child
forms, parameter constructor method, normal constructor, default
constructor, forward reference, sharing classes between forms.
Here is a newbie mistake that I found myself doing (as a newbie), and
that even a master programmer, the guru of this forum, Jon Skeet,
missed! (He knows this I'm sure, but just didn't think this was my
problem; LOL, I am needling him)
If...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 we have to send another system
| |
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |