/    Sign up×
Community /Pin to ProfileBookmark

Is possible to read URL file name and give it variable within page content?

Is possible to read URL file name and give it variable within page content?

Example:
[url]http://www.webdeveloper.com/forum/newthread.php?do=newthread&f=9[/url]

You have URL with [B]page name[/B]:newthread.php
and you have
values after ? like. ?do=newthread&f=9

Is technical possible (PHP) to detect page name (URL) and add value to page content like example: [B]page name[/B]

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@eval_BadCode_Jan 06.2011 — Use an output buffer. I don't see any use for doing this other than scraping data, and phishing attacks.

[code=php]<?php

ob_start();

echo "test.php1";

?>

test.php2

<?php

$page_data = ob_get_contents();
ob_end_clear();

echo preg_replace('/test.php/', "TEST.php?id=", $page_data);

?>[/code]
Copy linkTweet thisAlerts:
@eval_BadCode_Jan 06.2011 — Here's a working version:

[code=php]<?php

ob_start();
echo "test.php1";

?>

test.php2

<?php

$page_data = ob_get_contents();
ob_end_flush();
echo preg_replace('/test.php/', "TEST.php?id=", $page_data);



/* OUTPUT

test.php1
test.php2

TEST.php?id=1
TEST.php?id=2
*/
?>
[/code]
Copy linkTweet thisAlerts:
@toplisekauthorJan 07.2011 — thank you.
×

Success!

Help @toplisek spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...