PHP fdatasync() Function Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report The fdatasync() function is an inbuilt function in PHP that is used to synchronize changes to a file's data with the underlying storage device. This function is similar to the fsync() function, but it only synchronizes the file's data, not its metadata. Syntax: bool fdatasync(resource $stream) Parameters: This function takes one parameter which is described below: $stream: A file pointer resource that was obtained using the fopen() function. Return Value: The fdatasync() function returns true if the synchronization was successful otherwise it will return false. Example 1: The following program demonstrates the fdatasync() function. PHP <?php $fp = fopen('example.txt', 'w'); fwrite($fp, 'Hello, world!'); if (fdatasync($fp)) { echo "Changes to the file's data were successfully synchronized."; } else { echo "Failed to synchronize changes to the file's data."; } fclose($fp); ?> Output: Changes to the file's data were successfully synchronized. Example 2: The following program demonstrates the fdatasync() function. PHP <?php $fp = fopen('example.txt', 'w'); fwrite($fp, 'Hello, world!'); fdatasync($fp); fclose($fp); echo "Changes to the file's data were successfully synchronized."; ?> Output: Changes to the file's data were successfully synchronized. Reference: https://www.php.net/manual/en/function.fdatasync.php Comment More infoAdvertise with us Next Article Interview Preparation For Software Developers N neeraj3304 Follow Improve Article Tags : PHP PHP-function PHP-Filesystem Similar Reads Interview PreparationInterview Preparation For Software DevelopersMust Coding Questions - Company-wise Must Do Coding Questions - Topic-wiseCompany-wise Practice ProblemsCompany PreparationCompetitive ProgrammingSoftware Design-PatternsCompany-wise Interview ExperienceExperienced - Interview ExperiencesInternship - Interview ExperiencesPractice @GeeksforgeeksProblem of the DayTopic-wise PracticeDifficulty Level - SchoolDifficulty Level - BasicDifficulty Level - EasyDifficulty Level - MediumDifficulty Level - HardLeaderboard !!Explore More...Data StructuresArraysLinked ListStackQueueBinary TreeBinary Search TreeHeapHashingGraphAdvance Data StructuresMatrixStringAll Data StructuresAlgorithmsAnalysis of AlgorithmsSearching AlgorithmsSorting AlgorithmsPattern SearchingGeometric AlgorithmsMathematical AlgorithmsRandomized AlgorithmsGreedy AlgorithmsDynamic ProgrammingDivide & ConquerBacktrackingBranch & BoundAll AlgorithmsProgramming LanguagesCC++JavaPythonC#Go LangSQLPHPScalaPerlKotlinWeb TechnologiesHTMLCSSJavaScriptBootstrapTailwind CSSAngularJSReactJSjQueryNodeJSPHPWeb DesignWeb BrowserFile FormatsComputer Science SubjectsOperating SystemsDBMSComputer NetworkComputer Organization & ArchitectureTOCCompiler DesignDigital Elec. & Logic DesignSoftware EngineeringEngineering MathematicsData Science & MLComplete Data Science CourseData Science TutorialMachine Learning TutorialDeep Learning TutorialNLP TutorialMachine Learning ProjectsData Analysis TutorialTutorial LibraryPython TutorialDjango TutorialPandas TutorialKivy TutorialTkinter TutorialOpenCV TutorialSelenium TutorialGATE CSGATE CS NotesGate CornerPrevious Year GATE PapersLast Minute Notes (LMNs)Important Topic For GATE CSGATE CoursePrevious Year Paper: CS exams Like