Jump to content

Calling PHP Function


numaanc

Recommended Posts

Hi All

 

I've just registered - my first post :)  In my 6+ years of developing software, I've never had to post a question online but I am so baffled by this, I need some help guys!

 

I've got a class EnvDetails (storing the details of the environment i'm running my php in) and I'm trying to invoke a function like so

 

<html xmlns="http://www.w3.org/1999/xhtml">

<!--... css imports etc -->

<head>

    <title> My Page Title </title>

</head>

 

 

<?php

session_start();

   

require_once ($_SERVER["DOCUMENT_ROOT"]."/scripts/envUtil.php");

   

      ini_set('log_errors', true);

 

$details = EnvDetails::getInstance();   

if ($details->isLive())

      {

            $fileLocation="qa.log.txt";

            <!-- Other environment-specific stuff -->

        }

 

?>

<body>...</body>

 

 

 

 

My environemnt class :

 

 

class EnvDetails

{

      <!-- .... -->

public $ENV; //Either QA or LIVE

public function isLive()

{

return strcmp(self::$instance->ENV, "LIVE")==0;

}

}

 

 

When I open the page in a browser, php parses up to this much

$details = EnvDetails::getInstance();   

if ($details->

 

Then the page itself has isLive() and the rest of my php code. It looks like the php parser doesn't like the arrow ->  so it dumps out everything after but everything tells me this is how to call a function.

 

Some help please?

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/168039-calling-php-function/
Share on other sites

I think it more likely that the server isn't parsing the page as php, but rendering it as straight html.

<?php would be treated as a straight opening HTML tag (invalid of course, so simply not displayed) and the -> would correspond to the end of the tag... hence everything else after that point is displayed.

 

Can you do a straight <?php phpinfo(); ?>

?

Link to comment
https://forums.phpfreaks.com/topic/168039-calling-php-function/#findComment-886308
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.