syntax error, unexpected '(', expecting ']' [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
While trying to echo out a line, get an unexpected error for the following line:
echo "$arr[count($arr)]".')';
Cannot figure out what the fix might be. Want to print out the last item of the array.

Remove quotes and remember that array index starts from zero.
echo $arr[count($arr) - 1];
Or just:
echo end($arr);

try this:
echo '('.$arr[count($arr)].')';

Try this:
echo $arr[count($arr)];

Related

Getting Parse Error While Using Two Functions [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I am trying to write a program using Call By Reference to calculate the area but I am getting a Parse Error :-
Parse error: syntax error, unexpected 'ar' (T_STRING) in C:\xampp\htdocs\workspace.php on line 7
Now I, cannot think why it is happening?
<?php
function perimeter(&$l,&$b,&$result)
{
$result=2*($l+$b);
}
funtction ar(&$le,&$br,&$result1)
{
$result1=$le*$br;
}
$result=1;
$length=$_GET['length'];
$breadth=$_GET['breadth'];
echo "<h1><center>Area And Perimeter Calculator Using Call By Reference</h1></center>";
$result = perimeter($length,$breadth,$result);
echo "<br />The Perimeter Of The Rectangle Is <strong>$result</strong>";
$result= ar($length,$breadth,$result);
echo "<br /><br />The Area Of The Rectangle Is = <strong>$result</strong>";
?>
You misspelled function:
funtction ar(&$le,&$br,&$result1)
{
$result1=$le*$br;
}
should be
function ar(&$le,&$br,&$result1)
{
$result1=$le*$br;
}

PHP echo with space and without space [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am new to PHP and I am using PHP Version 5.4.17 in my mac. Below code with space gives me error. Once I remove the space in echo command, it gives me output but appended with Junk character. What am I doing wrong? Any help is appreciated
Code:
<?php
echo “Connection Success”;
?>
Error:
"Parse error: parse error, expecting ','' or';'' in /Library/WebServer/Documents/test org.php on line 2"
Code:
<?php
echo “ConnectionSuccess”;
?>
Output:
“ConnectionSuccessâ€
<?php
echo "ConnectionSuccess";
?>
You need to remove the bad quotes “ and ” and replace them with standard quotes: "
Some editors do this for you automatically, like BareBones.

What's error in below code of wrapping the path in double quotes? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
Following is my PHP code line:
$nic = "'".ADMIN_SITE_URL."'assets/img/watermark.png'";
$client->setWatermark($nic, 105, 148);
Here ADMIN_SITE_URL is a constant and I want to concatenate a string to this constant and wrap the whole sting into singlee quotes as this is going to be asigned as a parameter into a method named setWatermark(). But I'm not able to do it. Getting the error as:
PHP Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in pdf_test_question_paper.php on line 83
Errors parsing pdf_test_question_paper.php
I'm not getting why this is happening. Can anyone help me in resolving this issue? Any help would be greatly appreciated.
Try That
$nic = "'".ADMIN_SITE_URL."assets/img/watermark.png'";

explode function doesn't work [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
I have a String 7*10*6* I will separate the numbers, when I use explode function the out is:
Array
(
[0] => *
)
here is my code:
echo '<pre>';
print_r(explode('7*10*6','*'));
echo '</pre>';
what's the problem?
Oh boy, have you read the manual of explode?
the manual says:
explode(string $delimiter,string $string). You have done wrong. change your code to this:
print_r(explode('*','7*10*6'));
Try
print_r(explode('*','7*10*6'));
In explode function first argument is separator and second is string.

typo issue in php using html [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
i have this simple typo issue here i guess.
How can i resolve it?
<?php the_content("<br /> <span class='custom-more'>Read More: " . get_the_title('', '', false) "</span>"); ?>
I need to make a read more button in WordPress and i need to wrap the read more inside a span class.
I get this error message:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in
How am i supposed to resolve this?
Thanks
You are missing the concatenation operator . between get_the_title function and </span>
<?
php the_content("<br /> <span class='custom-more'>Read More: ".get_the_title('', '', false)."</span>");
?>
You are missing the concatenate (.)
Correct code will be
php the_content("<br /> <span class='custom-more'>Read More: ".get_the_title('', '', false)."</span>");

Categories