Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
How can I insert "echo" in an "include"
Old 02-15-2010, 09:00 PM How can I insert "echo" in an "include"
Skilled Talker

Posts: 54
Trades: 0
Example:

PHP Code:
<?
include('search.php?q=<?echo "EXAMPLE" ?>;');
?>
The internal <? ?> don't will work (<?echo "EXAMPLE" ?>), how can I solve it?
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
.Fernando is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-15-2010, 09:21 PM Re: How can I insert "echo" in an "include"
racer x's Avatar
Ultra Talker

Posts: 457
Name: Randy
Location: Northern Wisconsin
Trades: 0
You are already in php with the opening <? statement. (Which I like to write <?php)

You may be missing the theory of includes. You are not sending this to be displayed in the URL, you are requesting a file within your server. Like example.php would be a file you include into a page.
racer x is offline
Reply With Quote
View Public Profile Visit racer x's homepage!
 
Old 02-15-2010, 09:52 PM Re: How can I insert "echo" in an "include"
VirtuosiMedia's Avatar
Web Design Made Simple

Posts: 1,228
Trades: 0
I think you might be trying to do something like this:

PHP Code:
<?php

$example 
'example.txt';
include(
'includes/'.$example);

?>
__________________
Want new web resources every day? - Follow me on
Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
VirtuosiMedia is offline
Reply With Quote
View Public Profile Visit VirtuosiMedia's homepage!
 
Old 02-15-2010, 09:53 PM Re: How can I insert "echo" in an "include"
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
1. Since you are already in PHP mode you don't need to echo anything. I think what you are trying to accomplish is concatenating strings:
PHP Code:
$foo "example";
include(
'search.php?q=' $foo); 
2. Your approach appears to be incorrect (the code I posted above will fail). What exactly are you trying to do?

3. Using short tags (<? and <?=) is a bad idea. They will be removed in later versions of PHP and some people using older versions do not have them enabled (in other words using them leads to non-portable code). Use <?php instead.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 02-16-2010, 03:36 AM Re: How can I insert "echo" in an "include"
Experienced Talker

Posts: 41
Name: Adam B
Trades: 0
To clarify, trying to pass URL paramters through an include will result in a 404.
adam89 is offline
Reply With Quote
View Public Profile
 
Old 02-16-2010, 03:48 AM Re: How can I insert "echo" in an "include"
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Quote:
Originally Posted by adam89 View Post
To clarify, trying to pass URL paramters through an include will result in a 404.
Not quite.

If url file access is enabled and you use include or require with a url (ex include('http://mysite.com/somefile.php?foo=bar') ) then you will get whatever content that site servers to you (which could possibly be a 404 page).

If file url file access is disabled then include will look for a literal match to whatever input you gave it in the file system, almost certainly resulting in a warning (or an error if you use require).
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by NullPointer; 02-16-2010 at 03:50 AM..
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 02-16-2010, 04:00 AM Re: How can I insert "echo" in an "include"
Experienced Talker

Posts: 41
Name: Adam B
Trades: 0
Not sure I understand you here. What do you mean by 'URL file access enabled'?

When I said passing parameters through an include would result in a 404, I just generally meant that file will not be found (not a strict 404 server error). I was talking about PHP's "failed to open stream" warning/error. You cannot pass URL parameters through an include.
adam89 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How can I insert "echo" in an "include"
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.29627 seconds with 12 queries