This question already has answers here:
What is the difference between single-quoted and double-quoted strings in PHP?
(7 answers)
PHP - concatenate or directly insert variables in string
(15 answers)
Closed 1 year ago.
So how would you add a variable inside a do_shortcode(''); Basically i have a variable holding a URL which is what I want to add inside the url attributte, but i am not sure how to do it.
This is what I tried so far
<?php echo do_shortcode('[evp_embed_video url='"'. $video .'"' preload="auto" template="mediaelement"]'); ?>
but of course, it didn't work. Any advice on how to properly format this?
Related
This question already has answers here:
How do I pass variables and data from PHP to JavaScript?
(19 answers)
Send PHP variable to JavaScript function [duplicate]
(6 answers)
How to pass php variable to JavaScript function as parameter
(4 answers)
how to pass php variable to javascript?
(2 answers)
Closed 12 months ago.
I am having one onclick event with some paramters with it. But in some
cases i am getting double quaotes or space between strings. so getting
error of Uncaught SyntaxError: missing ) after argument list or
invalid token.
How to overcome with this issue. I tried to use array and trim the
variables but it wont work for me.
$stringArray = ['string 1', 'string'2','001'];
$concatenated = trim(implode(',',$stringArray));
E.g: I am getting 3 string like :
$data1 = 'surgery';
$data2 = 'Cardio'c';
$data3 = 'hopsital ab"cc';
<a id='changeState' onclick=editModal(\"". $data1 ."\",\"". $data2 ."\",\"".$data3."\");>Click Here</a>
Please help to resolve this issue.
This question already has answers here:
How can I combine two strings together in PHP?
(19 answers)
PHP String Concatenation With Variables [duplicate]
(1 answer)
Concatenating strings retrieved from form $_Post in php
(1 answer)
php String Concatenation, Performance
(12 answers)
Concatenate HTML string and variable in PHP [closed]
(3 answers)
Closed 2 years ago.
I was wondering if you can add a variable to a file-path.
Example:
path: C:\\users\\john\\school\\hardware.properties";
I want to make a variable of the word preceding the . (dot) - in this case, "hardware" - so the user can write a name in a form and search/get another property.
You can just make it a string and add the var into it
$name = $_POST['name']
$path = "C:/.../".$name.".properties"
I just make more sure what Jasper B want to write:
In your form you have some submit input and text input.
You will get datas from inputs so you will just access them like:
$name = $_POST["name"];
After you just put $name variable to path like:
$path = "C:\users\john\school\".$name.".properties";
This question already has answers here:
What is the difference between single-quoted and double-quoted strings in PHP?
(7 answers)
Closed 3 years ago.
my php code doesn't work inside a li tag.
I tried several things but it doesn't work.
echo '<li $page_title=="Cart" ? "class="nav-item active"" : "">';
I don't understand why it doesn't work, can someone help me with this code?
You can't execute php code inside of single quotes, and you can't do ternary operators inside of double quotes or single quotes. Store it in another variable and run it that way.
$class = ($page_title=='Cart') ? "class='nav-item active'" : '';
echo "<li $class>";
https://3v4l.org/uhQAi
This question already has answers here:
What is the difference between single-quoted and double-quoted strings in PHP?
(7 answers)
Closed 4 years ago.
I would like to assign a variable into the PHP code, which will change my URL. For example
$page = 'http://www.example.com/search-products?type=buildings&q=small&go=Go';
Where q=small i would like to change to say q=big (using a variable)
I have assigned a variable within PHP but i am unable to get it to work?
for example
$q= 'big';
$page = 'http://www.example.com/search-products?type=buildings&q=$q&go=Go';
The url does not however update - Any help would be appreciated
Use strings with " and not with ' if you're using variables in it.
$page = "http://www.example.com/search-products?type=buildings&q={$parameter}&go=Go";
Check this :
$page = "http://www.example.com/search-products?type=buildings&q={$q}&go=Go";
Note: Single quotes don't work in this case.
If you use Single quotes, you see something like this :
echo 'q={$q}';
//Output => q={$q}
This question already has answers here:
What is the difference between single-quoted and double-quoted strings in PHP?
(7 answers)
Closed 6 years ago.
first time asking here.
In php I need to insert a '$variable' as a string with the '$' sign into a $txt variable.
any ideas?
Thanks
Answer:
<?php $txt = '$variable' ?>
If you want know more how it works.
http://php.net/manual/en/language.types.string.php