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

  • Home
  • SEARCH
  • 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 7876937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:14:54+00:00 2026-06-03T03:14:54+00:00

I have an issue about writing HTML file with PHP. I have this function

  • 0

I have an issue about writing HTML file with PHP.

I have this function :

function openHTML ($file) {
 if (file_exists($file)) {
 $handle = fopen($file, "r");
 $output = fread($handle, filesize($file));
  fclose($handle);
 return $output; // output file text
 }else{
 return "This file is not exists";
 }
}

function saveHTML ($file,$string) {
 $a = fopen($file, 'w');
 fputs($a,stripslashes($string));
 fclose($a);
 return "success";
}

When I’m using openHTML it’s fine. But unfortunately, in file that I opened with openHTML() there are some &, and then I’m saving with saveHTML() but then string or codes that save stalled at char &.

Example : UPDATE !
I open blank file.html with openHTML() and I start to type some string bellow :

<html>
<head>
</head>
<body>
This is my login page & user page
</body>
</html>

After I save with code saveHTML():

<html>
<head>
</head>
<body>
This is my login page

At last code to be missing. Stalled at &.

I have using fputs, utf8_encode, fwrite, file_put_contents. Still not solved.

  • 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-06-03T03:14:54+00:00Added an answer on June 3, 2026 at 3:14 am

    try

        $output = htmlentities($output);
    

    on the string your going to save.

    check it out here

    It will change all HTML entities to their applicable charactors.
    In this case your & will be changed to

        &amp;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Read about the issue in this stackoverflow question . Still have the same issue
I have already searched about this issue, analyzed several open source tools (like Ganymed
I have read a lot about this issue but mine still seems to be
Please help me about this issue... In my application i have calender where user
I have an issue where if my json file looks like this { Numbers:
I have a 9000-line PHP file which consists of about 30 discrete areas, navigated
I am working on an application an have an issue about running shell command
I met an interesting issue about C#. I have code like below. List<Func<int>> actions
I have research about an issue and could not find a solution for it
I have an optimisation issue. It's about a product that contains 20 parts (the

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.