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.
Related
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 1 year ago.
Improve this question
I have a JSON like below format.
{
"title": "Title",
"content": "Content in **Markdown**"
}
Which could be queried if decoded as $json->title; and $json->content;,
I want to turn the content which is in Markdown to HTML,
I use Parsedown for this work.
<?php
include 'Parsedown.php';
$Parsedown = new Parsedown();
$file = file_get_contents('file.json');
$file = json_decode($file);
$Parsedown->text($file->content);
echo $file->content;
But still things appear not as expected.
If you are still not working then you are still not calling it correctly
$Parsedown = new Parsedown();
$file = file_get_contents('file.json');
$file = json_decode($file);
$file->content = $Parsedown->text($file->content);
echo $file->content;
The RESULT
<p>Content in <strong>Markdown</strong></p>
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 receive the following error message when I attempt to call a function which I need to push an object into an array:
array_push() expects parameter 1 to be array, null given
Any clues why this is happening? Thank you in advance :)
<?php
$programming = array();
//some unrelated lines of code here inbetween
function createProgramming($data){
global $programming;
$prog = new Programming($data);
array_push($programming, $prog);
}
?>
//random HTML here
<php?
createProgramming("str");
?>
//more html
$programming is only referenced in the code at those three locations present in my extract above.
That code works fine. There are few things that could make it break:
$programming is redefined / unset before createProgramming() is called
$programming is not defined in the global scope
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 am trying to pass a variable from a form to another php file to create an xml file.
<?php
$sentxt = $_POST['text']; //this comes from the form php
$params = array(
'answer_url' => 'to_xml.php?msg="$sentxt"',
);
$response = $p->make_xml($params);
echo "$sentxt";
?>
Whenever I try to run this I run into a problem
The xml file keeps outputting "$sentxt" instead of the string passed to the $sentxt via the php form post.
The echo "$sentxt"; displays the right string has been passed through properly, but the string is never passed into the array.
You should replace ' with " for string interpolation.
<?php
$sentxt = $_POST['text']; //this comes from the form php
$params = array(
'answer_url' => "to_xml.php?msg=$sentxt",
);
$response = $p->make_xml($params);
echo $sentxt;
?>
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've written a small code that get $_GET["page"] and if this exists, write the page $_GET["page"] . ".html" into a div (with echo). If this not exists, the page is "about.html". The problem is that and I've searched but I don't find the solution...
Fatal error: Function name must be a string in index.php on line 63.
If i go into a page that don't exists (for exampleindex.php?page=test) work (print "NOT FOUND") but if I go into a page that exists (for example index.php?page=about or simply index.php) don't work.
This is the code:
$page = "about";
if (isset($_GET["page"]))
if (!empty($_GET["page"]))
$page = $_GET["page"];
$page .= ".html";
$result = "NOT FOUND";
if (file_exists($page))
$result = $file_get_contents($page); //line 63
echo $result;
file_get_contents() not $file_get_contents()
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 messages page that loads communications between two users. The URL is message.php?u=[me]&p=[message parent id]&op=[other person], but $p and $op are not being defined in the page. When I echo each variable separately, $u appears everywhere from pre tag to the bottom of the document, but $p and $op do not echo anywhere. I tried deleting everything in .htaccess to see if that was causing a bug, but it wasn't. I can't think of what would cause this.
yourscript.php?var1=value1&var2=value2
You can use this by:
$var1 = $_GET['var1']; // $var1 = 'value1'
$var2 = $_GET['var2']; // $var2 = 'value2'
You can check whether or not these URL-parameters are set with isset()
(otherwise you create errors when you do not set them):
if (isset($_GET['var1'])) {
$var1 = $_GET['var1'];
} else {
die('usage: yourscript.php?var1=value1 !');
}