Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7049175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:58:52+00:00 2026-05-28T02:58:52+00:00

Thanks in advance. Getting this warning when using below code: Warning: file_get_contents(test.php) [function.file-get-contents]: failed

  • 0

Thanks in advance.

Getting this warning when using below code:

Warning: file_get_contents(test.php) [function.file-get-contents]: failed to open stream: No such file or directory in /path/index.php on line so-n-so.

Here’s the code I am using,

<?php

// Scan directory for files
$dir = "path/";
$files = scandir($dir);

// Iterate through the list of files 
foreach($files as $file)
{
// Determine info about the file
$parts = pathinfo($file);

// If the file extension == php
if ( $parts['extension'] === "php" )
{
// Read the contents of the file
$contents = file_get_contents($file);

// Find first occurrence of opening template tag
$from = strpos($contents, "{{{{{");

// Find first occurrence of ending template tag
$to = strpos($contents,"}}}}}");

// Pull out the unique name from between the template tags
$uniqueName = substr($contents, $from+5, $to);

// Print out the unique name
echo $uniqueName ."<br/>";
}
}
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:58:52+00:00Added an answer on May 28, 2026 at 2:58 am

    The error message says that the file isn’t found.

    This is because scandir() returns only the basename of the files from your directory. It doesn’t include the directory name. You could use glob() instead:

    $files = glob("$dir/*.php");
    

    This returns the path in the result list, and would also make your extension check redundant.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is the error that I am getting while using mysql_num_rows() function Error: Warning:
This is a total newbie question, so thanks in advance. I'm trying to get
I am getting a warning for the below code. //someother class #define EVENT_ID_DESCRIPTION_LEN 64
We've all seen this error before: Warning: require_once(test/blah.inc) [function.require-once]: failed to open stream: No
Thanks in Advance for reading and answer this question. I got button in asp
First of all thanks in advance, this has been very frustrating and I'm hoping
I am using c# .net. Thanks in advance for any help. I have searched
I am getting this warning in my jsf application when I upload an image
When I send e-mails using the package UTL_SMTP I am getting this error when
I'm using this code to parse XML in the instance variable response : @implementation

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.