Jump to content

Chris92

Members
  • Posts

    206
  • Joined

  • Last visited

About Chris92

  • Birthday 03/19/1992

Contact Methods

  • Website URL
    http://chrishemmens.com

Profile Information

  • Gender
    Male
  • Location
    Netherlands

Chris92's Achievements

Member

Member (2/5)

0

Reputation

  1. Well then I might as well just right it out in an if rather than a try statement and not bother catch it. Can you only catch ErrorExceptions in PHP?
  2. Is there any way to catch warnings without defining a warning handler? Example: try { $settings = parse_ini_file( 'main.ini' ); } catch( ErrorException $e ) { throw new ErrorException('No main configuration file found for webiste', '0003'); } Only ends up throwing a warning if the file doesn't exist. I want to catch it and throw an error.
  3. read the PHP documentation, he posted links on the functions. mkdir() makes a new directory: http://php.net/mkdir fopen() starts a new file stream: http://php.net/fopen once you have started a new stream you can write to it using fwrite(): http://php.net/fwrite and save it using fclose(): http://php.net/fclose I'll write you a small script: <?php $dir = 'myDir'; $file = 'myFile.php'; // check the directory to see if it already exists if( is_dir($dir) === false ) { // if it doesn't make a new directory mkdir($dir); } // start a new stream $f = fopen($file, 'w'); // 'w' for write // write the php to the stream fwrite( $f, '<?php echo "Hello world!"; ?>' ); // close the stream fclose($f); // include our new php script to see if it's working: include $myDir . '/' . $myFile; // Hello world! ?>
  4. You could get the file contents and then echo them along with a different header. <?php header('content-type: image/jpg'); echo file_get_contents('C:/MYFolder/SubFolder/Image.jpg'); ?> Or rather than even need to call the php script, base64 encode it and use that as the url (wouldn't recommend either). <?php $image = file_get_contents('C:/MYFolder/SubFolder/Image.jpg'); $base64 = base64_encode($image); echo '<img src="data:image/jpg;base64,'. $base64 .'" alt="" />'; ?>
×
×
  • 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.