2

I want to load contents from external HTML sites via GET.

PHP:

<?php
 $content = file_get_contents('template/' . $_GET['l'] . "/" + $_GET['n'] . ".html");
?>

So I want to call this page: (page root)/template/html/1.html

Now if I do so by adding the parameters within the URL (file.php?l=html&n=1), I get nothing displayed. Why is this?

6
  • 2
    Have you tried hardcoding it and see if that works? Your snippet does not "echo" anything so that might be it too. Commented Jan 18, 2014 at 23:22
  • @FabienWarniez I do <?php echo $content; ?> in my main PHP file. Commented Jan 18, 2014 at 23:22
  • 3
    You are using + instead of . to concatenate your strings. Use . Commented Jan 18, 2014 at 23:23
  • @Pekka웃 Changed it, still doesn't work. Commented Jan 18, 2014 at 23:25
  • Do an echo 'template/' . $_GET['l'] . "/" + $_GET['n'] . ".html" and see whether the path really is correct. Are you sure you are in the right directory? Commented Jan 18, 2014 at 23:26

1 Answer 1

1

Use . instead of + to concatenate.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.