-
Notifications
You must be signed in to change notification settings - Fork 0
/
IO.class.php
43 lines (36 loc) · 965 Bytes
/
IO.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
/**
* User: Guillem LLuch
* Date: 17/12/16
* Time: 20:19
*/
namespace glluchcom\csdlExtractor;
/**
* Class SaveResults Save generic objects in a file.
* @package glluchcom\csdlScraping
*/
class IO
{
/**
* Save an object with serialize function from php.
* @param $thing The object to be serizalized
* @param $filename The name of file where the object will be saved.
* @return int The value returned by the php function file_put_contents
*/
public static function phpFormat($thing, $filename)
{
$phpThing = serialize($thing);
return file_put_contents($filename, $phpThing);
}
public static function obtainPhpFormat($filename)
{
return unserialize($filename);
}
public static function xmlFile2Object($filename)
{
$string = file_get_contents($filename);
$xml = simplexml_load_string($string);
//print_r($xml);
return $xml;
}
}