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 7557031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:01:14+00:00 2026-05-30T12:01:14+00:00

When I processed the following file src.php : <?php include params.php; ?> Str 1

  • 0

When I processed the following file src.php:

<?php
include "params.php";
?>
Str 1
val a = <?=$b?>
Str 3

where the params.php file:

$b = 123;

$ php src.php > tgt.txt

I get the result:

Str 1
val a = 123Str 3

instead of

Str 1
val a = 123
Str 3

How shoud I solve this problem? Should I add an additional line break after <?=b?> through all my code?

  • 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-30T12:01:16+00:00Added an answer on May 30, 2026 at 12:01 pm

    This is an issue I’ve come across before with the way PHP blocks are processed, the first line-break after ?> is, as far as I know, always ignored. This is probably[citation needed] to avoid problems when using ‘code only’ PHP files which would output a trailing newline when include‘d, e.g.:

    -- some_file.php
    <?php
    // some class/function definitions, etc.
    ?>
    + trailing newline
    
    -- some_other_file.php
    include 'some_file.php'; // this would actually output a linebreak
    

    As a lot of UNIX editors enjoy messing around with your whitespace this was probably seen as a necessary ‘feature‘ in order to avoid this issue.

    TL;DR:

    The only workaround I’m aware of is to either concatenate a linebreak to your output

    <?= $b.PHP_EOL ?>
    

    or add another linebreak in the HTML

    val a = <?= $b ?>
    
    Str 3
    

    Both of these solutions suck, but I don’t know any other way around.

    EDIT: A different approach would be to use heredoc strings:

    echo <<<STUFF
    Str 1
    val a = $b
    Str 3
    STUFF;
    // must be a break after `STUFF;`
    

    That way formatting is still clear, and it behaves as you’d expect it (though a caveat with heredocs is there must be a linebreak after the terminating STUFF;, or you’ll get a parse error, at least on 5.4).

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

Sidebar

Related Questions

I have the following declaration in my build.xml file, in my src folder I
I have used following code for retrieving content from a csv file. <?php $fo
I have the following code: ifstream initFile; initFile.open(D:\\InitTLM.csv); if(initFile.is_open()) { // Process file }
When I do the following ps -aef|grep asdf I get a list of processes
I am trying to get the memory space of a process using the following
I've got the following HTML form. As you can see it's saving a file.
I have the following basic code to read a text file from a StreamReader:
I have the following PowerShell script that will parse some very large file for
Please, We have the following situation: Component X that divides a request file into
I need to execute a batch file (in Java 6) and use following code

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.