How can use tab space in variable [closed] - php

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
"\t" is not working on my code
Tried to put a lot on .' '.
$name = '<h4 class="h4">NAME: '."\t".$firstname .' '. $midname .' '. $lastname. '</h4>';
Expected out put is
NAME: Mark stack

Put the Name: inside the <span>Name:</span> and set margin-right to the span to get your desired space.
echo $name = '<h4 class="h4"><span style = "margin-right: 20px;">NAME:</span> '.$firstname .' '. $midname .' '. $lastname. '</h4>';
Demo

html syntax cant read tab.... it dosent know it , as a charachter.
use this. <pre></pre>

Related

How to structure php if statement to check for smartquote [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
In a db returned record, the var $bookTitle either starts with a smartquote or does not. If the first character is a smartquote, I want to display the record as-is. If the first character is anything else (letter or number), I want the concatenated string to be italicized. I've tried a couple different ways to structure the == '"' without success. The current version is italicized, no matter what is returned (NOTE: the code pasted here won't correctly depict smartquotes).
EDIT: The only part of the statement not working is the ($titleFormat == '"').
EDIT: I discovered that running echo $titleFormat returns a black diamond with a question mark.
<?php
$titleFormat = $bookTitle[0];
if ($titleFormat == '"') {
echo $Parsedown->text($bookTitle . ' ' . $bookSubtitle);
}
else { ?>
<em><?php echo $Parsedown->text($bookTitle . ' ' . $bookSubtitle); ?></em>
<?php
} ?>
Have you tried checking with regex...
if ( preg_match( '/^"|^“/', $bookTitle ) ) {
echo $Parsedown->text( $bookTitle . ' ' . $bookSubtitle );
} else {
printf( '<em>%s</em>', $Parsedown->text( $bookTitle . ' ' . $bookSubtitle ) );
}
Have you also considered that the db result might be encoded, for example: "?
Could it be that the character isn't actually " but “ instead? I've updated the regex above.

echoing javascript not displaying any data [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I am confused as to why this piece of simple code is not displaying any data in either console.log or .actions class. There are no errors in console and I can see the correct value being returned in the payload window in inspector.
I would be grateful if someone could point out my error. Many thanks
<?php
$value = '10';
echo '<script>';
echo 'var value = ' . json_encode($value) . ';';
echo '$(".actions").text(value);';
echo 'console.log(value);';
echo '</script>';
?>
Make sure that jQuery is imported before your script, try this example.
<?php $value = '10';?>
<p class='actions'>Loading...</p>
<script src="jquery.min.js"></script>
<noscript>Javascript is disabled!</noscript>
<script>
$(function(){
var str = 'value = <?=$value?>';
$('.actions').text(str);
console.log(str);
});
</script>

Infinite loop. Why? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
i wanna test if my variable is empty or not to display some differents things.
When i don't use the else...if everything work but when i use this code :
<?php
$Amazon = get_post_meta($post->ID, "Lien Amazon", true);
?>
<?php
if( $Amazon != NULL ){
echo '<li><span class="post-meta-key">Acheter sur Amazon</li>' ;}
else {
echo '<li><span class="post-meta-key">Acheter sur Amazon</li>' ;}
?>
What is the problem ? Thank you
Here is an output error. You haven't closed and reopened the string on trying to concat a variable.
echo '<li><span class="post-meta-key">Acheter sur Amazon</li>' ;
Do instead:
echo '<li><span class="post-meta-key">Acheter sur Amazon</li>' ;

php mysql / link not producing results [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
the link within the string is producing the results page just fine. However, no content is being displayed. Here is the string:
echo '<td>' . substr($row['DESCR'], 0, 40) . '</td>';
What could I do in order to get the content to display on the results page? thank You
I've added the new code, and unfortunately now, its not echoing out the string itself
echo '' . substr($row[\'DESCR\'], 0, 40) . '';
is producing a blank page.
You have space issue in the link,
Change
echo '<td>' . substr($row['DESCR'], 0, 40) . '</td>';
To
echo '<td>' . substr($row['DESCR'], 0, 40) . '</td>';

php string two echo statements together [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
this string is breaking my code and I am not sure why. If anyone can help me correct it I would appreciate it.
if ($p == $url) { echo '<li><a class="active" href="index.php?p=' . $url . '">'
. $label . '</a></li>'; } else { echo '<li>' . $label . '</li>'; }
htmlspecialchars(urlencode($url)) and htmlspecialchars($label). The rest seems fine.

Categories