Home > Net >  Concatenating strings in PHP using require() without printing 1 as part of the output
Concatenating strings in PHP using require() without printing 1 as part of the output

Time:11-26

My question is related to enter image description here

Do you have specific suggestions to refactor my code to get rid of that '1' or maybe php.ini or some configuration can help in this case? Thank you.

CodePudding user response:

I see that your scala-programming-projects/scala-programming-projects-book-info.php already concat the string. just remove concatenation on index.php

<?php
  require("page.php");
  $index = new Page();
  
  require("scala-programming-projects/scala-programming-projects-book-info.php");
  require("success-habits-dummies-zeller/success-habits-dummies-zeller-book-info.php");
  .....
  .....
  .....
  $index->Display();
?>

CodePudding user response:

$index->content .=
  require("scala-programming-projects/scala-programming-projects-book-info.php");
  require("success-habits-dummies-zeller/success-habits-dummies-zeller-book-info.php");

Instead of doing this ,you could get the output of the require calls into a variable using output buffering. as an example ,

ob_start();
require('bla.php');
require('blabla.php');
 $index->content .= ob_get_clean();
  •  Tags:  
  • php
  • Related