This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to concatenate echos
I want to concatenate wordpress option setting value (get_option('my_option_value') with css class in php file.
My css class are box-one ,box-two, box-three. While (get_option('my_option_value') gives value one,two and three according to option setting.How can I concatenate class="box-"
and (get_option('my_option_value')?
In your HTML, insert PHP inline with :
class="box-<?php echo get_option('my_option_value'); ?>" ...
Related
This question already has answers here:
How to turn off html escape in Smarty
(2 answers)
Closed 2 years ago.
Good morning,
I have variable with HTML code. For example:
{assign var="url" value="<a href='google.com'>URL</a>" nocache}
The next step is display the content.
{$url}
The result is:
<a href='google.com'>URL</a>
How to display the URL which will be a working link?
Kind regards
The answer is to add nofilter parameters to variable:
{$url nofilter}
This question already has answers here:
Get text between HTML tags [duplicate]
(3 answers)
Closed 6 years ago.
I need to get the Text value of a HTML a link dynamically stored in PHP variable like
$term = 'Meat';
so the result will be Meat only. can you please let me know how to do this? Thanks
You could strip all tags from the text using strip_tags
echo strip_tags($term);
echoes: Meat
Reference: http://php.net/manual/en/function.strip-tags.php
This question already has answers here:
How can I get parameters from a URL string?
(12 answers)
Closed 6 years ago.
i have a page in HTML which get in input an "id" variable by URL:
registration.html?id=123456789
Now i want use this "id" variable into an href variable inside registration.html file to write the "id" input parameter of php file described on href
Can I get some help?
Thanks
Firstly, it will need to be a .PHP file for any PHP code to execute.
Despite that, you're going to want to output $_GET['id']
This question already has an answer here:
How can I access a property with an invalid name?
(1 answer)
Closed 6 years ago.
I have a question about attributes in PHP.
I have various Class with the same attributes, but with with different prefix.
Example:
$attr->a_field;
$attr2->b_field;
So, with another Class I want to access to them.
I tried:
$field = "{$prefix}_field";
$attr->{$field}
and it works perfect. But is any other way to doing this?
I tried also with:
$attr->{$prefix}_field;
$attr->{$prefix}{"_field"};
$attr->"{$prefix}_field";
etc and who I suppose I get PHP's errors
Thanks!
You can write it directly as $attr->{"{$prefix}_field"}, as shown in the docs.
You're looking into variable variables
$attr->{$prefix."_field"}
This question already has answers here:
Redefining constants in PHP
(5 answers)
Closed 8 years ago.
I have a php file like this.
define('TEXT_ONE', 'testvalue1');
define('TEXT_TWO', 'testvalue12');
define('TEXT_THREE', 'testvalue13');
define('TEXT_FOUR', 'testvalue14');
define('TEXT_FIVE', 'testvalue15');
define('TEXT_SIX', 'testvalue16');
define('TEXT_SEVEN', 'testvalue17');
define('TEXT_EIGHT', 'testvalue18');
define('TEXT_NINE', 'testvalue19');
define('TEXT_TEN', 'testvalue10);
define('TEXT_ELEVEN', 'testvalue11');
I want to change some of the defined value through php code.
for ex:- I Want to change above file to
define('TEXT_ONE', 'newtext1');
define('TEXT_TWO', 'newtext12');
define('TEXT_THREE', 'newtext13');
define('TEXT_FOUR', 'newtext14');
define('TEXT_FIVE', 'newtext15');
define('TEXT_SIX', 'newtext16');
define('TEXT_SEVEN', 'newtext17');
define('TEXT_EIGHT', 'newtext18');
define('TEXT_NINE', 'testvalue19');
define('TEXT_TEN', 'newtext10);
define('TEXT_ELEVEN', 'testvalue11');
Can any one help me?
Thanks
define — Defines a named constant.
As the name suggests, that value cannot change during the execution of the script