My PHP file isn't showing anything? [closed] - php

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 have a PHP file.
<?
$user = "hi";
echo $user;
?>
And nothing happens, its just blank. It should say "hi". I am using xampp to run the PHP and it is saved in the right place but nothing happens.

you should use <?php instead of <?
try this:
<?php
$user = "hi";
echo $user;
?>
or Set
short_open_tag=On
in php.ini
And restart your Apache server.

You need to activate php short open tag from php settongs or replace : <? with <?php

Related

how to add string to variable in php? [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 6 years ago.
Improve this question
i just need on small info i want just add '#' to one variable and and put add thing into one variable. i am adding small php code to here please suggest me.
<?php
$email34 = $row['email'];
$rem = '#gmail.com';
$trim_email = str_replace($rem ,'', $email34);
$tag_name ="#".$trim_emial.;
echo $tag_name;
?>
but i am getting only # as output;
but my out should be "#mahesh1" if any have idea about this code please help me. thank you advanced.
there is so much spelling mistakes in the variables... try below given code
<?php $email34 = $row['email'];
$rem = '#gmail.com';
$trim_email = str_replace($rem ,'', $email34);
$tag_name ="#".$trim_email;
echo $tag_name;
?>

I'm running into an error with the following snipet here [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 7 years ago.
Improve this question
I'm running into an error with the following snipet here
<?php
echo '<script type="text/javascript">';
echo 'alert("Your input value is invalid");';
echo '</srcipt>';
?>
Though it was given in the comment I guess the OP still can't able to get it, to make end,
Here's the answer
You have typo in the srcipt instead of script
Just change it inside your code, then everything will work fine
<?php
echo '<script type="text/javascript">';
echo 'alert("Your input value is invalid");';
echo '</script>';
?>
And i recommend you to do it in a single line instead of having three echo
<?php
echo '<script type="text/javascript">alert("Your input value is invalid");</script>';
?>

PHP console does not echo [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
Okay this really strange or I am missing something. When I run this very simmple PHP script on cmd I get the expected output which is 0. but when I uncomment the last two lines of code. . .nothing is displayed.
<?php
$test1 = 0;
echo $test1;
$test2 = 0;
#$test1_weight = 0:
#$test2_weight = 0;
?>
Is there some rule against declaring variables after an echo statement?
$test1_weight = 0:
--> change ":" to ";"
No there is no rule against declaring variables after an echo statement

Store a variable in a external file [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
How can I store a variable in an external file?
Heres the code:
index.php:
<?php
$info=file('sites/test.php')
$titel=trim($info[1]);
echo $title;
?>
sites/test.php:
line1
line2
line3
What I would like index.php to output:
line1
I cant use include_once, because I only want the first line from sites/test.php
Spoonfeeding, I know:
<?php
$info=file('sites/test.php');
$title=trim($info[0]);
echo $title;
?>
Try this:
<?php
$d=explode("\n", file_get_contents('sites/test.php'));
echo $d[0];

simplexml_load_file() with a variable [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 9 years ago.
Improve this question
I'm currently having an issue with simplexml_load_file(); my xml path is a url, that is rendered as a variable
$xurl = "domain/pathto/myfile.xml"; // This is actually a variable that returns the entire URL to where my xml file is -- this will change from file to file
$xmlpath = parse_url($xurl, PHP_URL_PATH); // to get the path of my xml file ex. /pathto/myfile.xml
$xmlpath = mb_substr($xmlpath, 1); // returns pathto/myfile.xml
here is where my problem is, when I put it into :
simplexml_load_file($xmlpath);
In my function, I get nothing appearing from the XML file
However, in my same function if I change it to
simplexml_load_file("pathto/myfile.xml");
My function works fine.
I did an echo on $xmlpath and it returns the pathto/myfile.xml just fine.
<?php echo $xmlpath; ?> // returns pathto/myfile.xml
What am I doing wrong?
EDIT: Phil
echo strcmp("pathto/myfile.xml", $xmlpath)
returns a 0.

Categories