M
M
Maxim Tyulpakov2015-11-09 15:36:47
PHP
Maxim Tyulpakov, 2015-11-09 15:36:47

How to assign the result of echo to a variable?

echo date("d ".$month[date('n')]." Y"),'<br>';
as a result, the date will be displayed in the form of November 09, 2015
How to assign this result to $data ? For example this code:

<?php 
$data =  echo date("d ".$month[date('n')]." Y"),'<br>'; //куда это все засунуть, кавычки, скобки, квадратные скобки? 
$data
?>

Brought me out stupidly -
November 09, 2015
I'm sorry, the whole jamb was in the assignment <br>removed it, and everything became as I needed :)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey, 2015-11-09
@MaXComp

$data =  date("d ".$month[date('n')]." Y"); 
echo $data.'<br>';

V
Visphord, 2015-11-09
@Visphord

Well, or like this, if the very principle of intercepting data from echo is interesting:

ob_start();
echo "Привет ";
$out1 = ob_get_contents();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question