Jump to content

Catchable fatal error...


android6011

Recommended Posts

This is the code:

 

<?

// Instantiate a new COM client to iTunes
$iTunes = new COM('iTunes.Application');

// What's playing now?
$currentTrack = $iTunes->CurrentTrack;
$trackName = $currentTrack->Name;
$trackNumber = $currentTrack->TrackNumber;
$albumName = $currentTrack->Album;
$artistName = $currentTrack->Artist;

echo $currentTrack;

 

This is what I get:

 

 

Catchable fatal error: Object of class variant could not be converted to string in E:\xampp\htdocs\itunes.php on line 18

 

Link to comment
Share on other sites

I'm not positive what is causing your error; but I found this on php.net :::::::::::

 

 

 

As of (at least) PHP 5.2, you can no longer convert an object to a string unless it has a __toString method. Converting an object without this method now gives the error:

 

PHP Catchable fatal error:  Object of class <classname> could not be converted to string in <file> on line <line>

 

Try this code to get the same results as before:

 

<?php

 

if (!is_object($value) || method_exists($value, '__toString')) {

    $string = (string)$value;

} else {

    $string = 'Object';

}

 

?>

 

 

---------

 

Hope that helps.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.