March 18, 2013

Add php within a string

Question by Brown

I want to take

$imgsrc = get_template_directory_uri() . '/s.php?strings=';

and add the_content_rss('', TRUE, '', 4) after strings.

How do I go about doing that?

$imgsrc = get_template_directory_uri() . '/titles.php?strings=' . the_content_rss('', TRUE, '', 4);

doesn’t seem to output a single URL.

Answer by Starx

First thing that you should understand is

String concatenation requires functions that return value not output/echo them.

So, make sure get_template_directory_uri() and the_content_rss('', TRUE, '', 4); returns a value instead of displaying them. If both functions return a value, the URL should be build as expected.

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+


Please fill the form - I will response as fast as I can!