# PHP string + value to RoR

**URL:** <https://www.ruby-forum.com/t/php-string-value-to-ror/159396>\
**Category:** Rails\
**Created:** [February 4, 2009, 7:07am UTC](https://www.ruby-forum.com/t/php-string-value-to-ror/159396 "2009-02-04T07:07:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnroyworld](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bcef8e/32.png) [@johnroyworld](https://www.ruby-forum.com/u/johnroyworld)\
**Post date:** [February 4, 2009, 7:07am UTC](https://www.ruby-forum.com/t/php-string-value-to-ror/159396/1 "2009-02-04T07:07:00Z")

</div>

hello I’m new to RoR and i have concern regarding on how to output a  
string with a value that parse on it.

Example in php:  
$value = 1;  
$string = ‘the value is ‘.$value.’.’;

and it gives you the output which is: “the value is 1.” so how we are  
going to do it in RoR. Any help would be appreciated. I know its very  
simple to the one who knows it. Forgive me im only a newbie. Thank you!

---

<div class="post-metadata">

**Author:** ![johnroyworld](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bcef8e/32.png) [@johnroyworld](https://www.ruby-forum.com/u/johnroyworld)\
**Post date:** [February 4, 2009, 7:11am UTC](https://www.ruby-forum.com/t/php-string-value-to-ror/159396/2 "2009-02-04T07:11:13Z")

</div>

Johnroy W. wrote:

> hello I’m new to RoR and i have concern regarding on how to output a  
> string with a value that parse on it.
> 
> Example in php:  
> $value = 1;  
> $string = ‘the value is ‘.$value.’.’;
> 
> and it gives you the output which is: “the value is 1.” so how we are  
> going to do it in RoR. Any help would be appreciated. I know its very  
> simple to the one who knows it. Forgive me im only a newbie. Thank you!

myvalue = 1  
mystring = 'the value is ’ + myvalue.to\_s + ‘.’

Cheers,  
Darrik

–  
Darrik Mazey  
Developer  
DMT Programming, LLC.  
P.O. Box 91  
Torrington, CT 06790  
office: 330.983.9941  
fax: 330.983.9942  
mobile: 330.808.2025  
removed\_email\_address@domain.invalid

To obtain my public key, send an email to  
removed\_email\_address@domain.invalid.

---

<div class="post-metadata">

**Author:** ![johnroyworld](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bcef8e/32.png) [@johnroyworld](https://www.ruby-forum.com/u/johnroyworld)\
**Post date:** [February 4, 2009, 7:30am UTC](https://www.ruby-forum.com/t/php-string-value-to-ror/159396/3 "2009-02-04T07:30:45Z")

</div>

Or use interpolation with double-quotes:

myvalue = 1  
mystring = “the value is #{myvalue.to\_s}.”

– Josh  
[http://iammrjoshua.com](http://iammrjoshua.com)

Darrik Mazey wrote:

> Johnroy W. wrote:
> 
> > hello I’m new to RoR and i have concern regarding on how to output a  
> > string with a value that parse on it.
> > 
> > Example in php:  
> > $value = 1;  
> > $string = ‘the value is ‘.$value.’.’;
> > 
> > and it gives you the output which is: “the value is 1.” so how we are  
> > going to do it in RoR. Any help would be appreciated. I know its very  
> > simple to the one who knows it. Forgive me im only a newbie. Thank you!
> 
> myvalue = 1  
> mystring = 'the value is ’ + myvalue.to\_s + ‘.’
> 
> Cheers,  
> Darrik
> 
> –  
> Darrik Mazey  
> Developer  
> DMT Programming, LLC.  
> P.O. Box 91  
> Torrington, CT 06790  
> office: 330.983.9941  
> fax: 330.983.9942  
> mobile: 330.808.2025  
> removed\_email\_address@domain.invalid
> 
> To obtain my public key, send an email to  
> removed\_email\_address@domain.invalid.

---

<div class="post-metadata">

**Author:** ![johnroyworld](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bcef8e/32.png) [@johnroyworld](https://www.ruby-forum.com/u/johnroyworld)\
**Post date:** [February 4, 2009, 9:31am UTC](https://www.ruby-forum.com/t/php-string-value-to-ror/159396/4 "2009-02-04T09:31:18Z")

</div>

\<% value = 1 %\>  
The value is \<%= value %\>

Read the getting started guide on [http://guides.rubyonrails.com](http://guides.rubyonrails.com) and  
that will teach you a lot

On 04/02/2009, at 16:07, Johnroy W. \<rails-mailing-list@andreas-

---

<div class="post-metadata">

**Author:** ![johnroyworld](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bcef8e/32.png) [@johnroyworld](https://www.ruby-forum.com/u/johnroyworld)\
**Post date:** [February 4, 2009, 5:36pm UTC](https://www.ruby-forum.com/t/php-string-value-to-ror/159396/5 "2009-02-04T17:36:54Z")

</div>

Ryan B. wrote:

> \<% value = 1 %\>  
> The value is \<%= value %\>

or  
\<% value = 1 %\>  
The value is \<%= h(value) %\>

In case you don’t trust the “value” of value. The h (http\_escape) method  
will help protect you against injection attacks.

---

<div class="post-metadata">

**Author:** ![johnroyworld](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bcef8e/32.png) [@johnroyworld](https://www.ruby-forum.com/u/johnroyworld)\
**Post date:** [February 4, 2009, 5:38pm UTC](https://www.ruby-forum.com/t/php-string-value-to-ror/159396/6 "2009-02-04T17:38:54Z")

</div>

Robert W. wrote:

> The value is \<%= h(value) %\>

Oops! Previous post was a bad example. Assume value was taken from user  
input, which in that case you should escape it to make it safe.
