Jump to content

Add <?php Echo $_get["q"]; ?> In My Php Code


bondigor69

Recommended Posts

hey guys I want to add
   <?php echo $_GET["q"]; ?>[/indent]

instead of "news" in this PHP code

 

 

   <?php
   $rss = new DOMDocument();
   $rss->load('http://wordpress.org/news/feed/');
   ?>[/indent]

 

How can I do that

Thank you for help

If someone posts a solution,
Edited by bondigor69
Link to comment
Share on other sites

1. If the "q" is set then use it, otherwise use a default value.

2. Validate it. It should be one of "news" or whatever else is valid for that feed. If it's not valid then do something besides ignore the problem.

3. Stick it in the string. There are many ways to do this and if you know even the smallest amount of PHP then you can do it.

Link to comment
Share on other sites

Hey dude, give this a try:

<?php

$_GET['q'] = (isset($_GET['q'])) ? $_GET['q'] : "some_default_value";

$rss->load("http://wordpress.org/{$_GET['q']}/feeds/");

?>

 

Let me know how you get on.

 

Regards,

 

L2c.

yeahhhhh man you're amazing. thank you so much it works fine for me

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.