PHP | XMLWriter startComment() Function Last Updated : 07 Mar, 2024 Comments Improve Suggest changes Like Article Like Report The XMLWriter::startComment() function is an inbuilt function in PHP which is used to start comment. This comment later needs to be closed using XMLWriter::endComment() function. Syntax: bool XMLWriter::startComment( void ) Parameters:This function doesn’t accept any parameter. Return Value: This function returns TRUE on success or FALSE on failure. Below examples illustrate the XMLWriter::startComment() function in PHP: Example 1: php <?php // Create a new XMLWriter instance $writer = new XMLWriter(); // Create the output stream as PHP $writer->openURI('php://output'); // Start the document $writer->startDocument('1.0', 'UTF-8'); // Start a element $writer->startElement('div'); // Start a comment $writer->startComment(); // Add text to the comment $writer->text('This is a comment'); // End the comment $writer->endComment(); // End the element $writer->endElement(); // End the document $writer->endDocument(); ?> Output: <?xml version="1.0" encoding="UTF-8"?> <div><!--This is a comment--></div> Program 2: php <?php // Create a new XMLWriter instance $writer = new XMLWriter(); // Create the output stream as PHP $writer->openURI('php://output'); // Start the document $writer->startDocument('1.0', 'UTF-8'); // Start a element $writer->startElement('div'); // Start a comment $writer->startComment(); // Add text to the comment which will not be visible $writer->text('This will not be visible.'); // End the comment $writer->endComment(); // Add value to the element $writer->text('This is the visible text.'); // End the element $writer->endElement(); // End the document $writer->endDocument(); ?> Output: <?xml version="1.0" encoding="UTF-8"?> <div><!--This will not be visible.--> This is the visible text.</div> Comment More infoAdvertise with us Next Article Company-wise Practice Problems G gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-XML 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