PHP正在显示我的源代码?(PHP is displaying my source code?)
我刚刚升级到php5.3,当我执行时:
php myfile.php
我看到了myfile.php的源代码。
知道为什么会这样吗? 我以前从未见过这样的东西!
I just upgraded to php5.3 and when I execute:
php myfile.php
I see the source code for myfile.php.
Any idea why this is happening? I've never seen anything like it before!
原文:https://stackoverflow.com/questions/1570581
更新时间:2023-05-22 17:05
最满意答案
根据我的理解,您希望在
MyFavorite
课程中做这样的事情- (id)initWithCoder:(NSCoder *)aDecoder { _location = [aDecoder decodeObjectForKey:@"location"]; _isOnNotificationsScreen = [aDecoder decodeObjectForKey:@"notificationScreen"]; } - (void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:self.location forKey:@"location"]; [aCoder encodeObject:self.isOnNotificationsScreen forKey:@"notificationScreen"]; }
From what I understand your going to want to do something like this in your
MyFavorite
class- (id)initWithCoder:(NSCoder *)aDecoder { _location = [aDecoder decodeObjectForKey:@"location"]; _isOnNotificationsScreen = [aDecoder decodeObjectForKey:@"notificationScreen"]; } - (void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:self.location forKey:@"location"]; [aCoder encodeObject:self.isOnNotificationsScreen forKey:@"notificationScreen"]; }
相关问答
更多-
实际上,您需要将自定义对象存档到NSData然后将其保存为用户默认值并从用户默认值中检索并再次取消归档。 你可以像这样归档它 let teams = [Team(id: 1, name: "team1", shortname: "t1"), Team(id: 2, name: "team2", shortname: "t2")] var userDefaults = UserDefaults.standard let encodedData: Data = NSKeyedArchiver.archived ...
-
尝试将非属性列表对象设置为NSUserDefaults(Attempt to set a non-property-list object as an NSUserDefaults)[2023-09-01]
您发布的代码尝试将一组自定义对象保存到NSUserDefaults 。 你不能这样做 实现NSCoding方法没有帮助。 您只能在NSUserDefaults存储NSArray , NSDictionary , NSString , NSData , NSNumber和NSDate NSUserDefaults 。 您需要将对象转换为NSData (就像您在某些代码中),并将NSData存储在NSUserDefaults 。 如果需要,您甚至可以存储NSData的NSArray 。 当您读回数组时,您需要取 ... -
在plist中,键必须是字符串。 由于NSUserDefaults由plist支持,因此它会强制执行该限制。 作为旁注,我认为使用[@{...} mutableCopy]会更清楚。 In a plist, the keys have to be strings. Since NSUserDefaults is backed by a plist, it enforces that restriction. As a sidenote, I think it would be clearer for you ...
-
根据我的理解,您希望在MyFavorite课程中做这样的事情 - (id)initWithCoder:(NSCoder *)aDecoder { _location = [aDecoder decodeObjectForKey:@"location"]; _isOnNotificationsScreen = [aDecoder decodeObjectForKey:@"notificationScreen"]; } - (void)encodeWithCoder:(NSCoder *)a ...
-
尝试设置非属性列表对象 - NSUserDefaults(Attempt to set a non-property-list object - NSUserDefaults)[2021-11-17]
你不能在那里有空。 属性列表不支持显式的空值 维基百科 You can't have null in there. property lists do not support explicit nulls Wikipedia -
您不能直接在NSUserDefaults存储NSURL ,只能存储NSData , NSString , NSNumber , NSDate , NSArray或NSDictionary ; 此外,任何NSArray或NSDictionary可能只包含这些类型的对象。 您必须将NSURL转换为这些类型之一,很可能通过使用absoluteString将它们转换为NSString。 You can't directly store an NSURL in NSUserDefaults, only NSData, ...
-
categoriesArray = [[NSMutableArray alloc]init]; categoriesArray = [[[NSUserDefaults standardUserDefaults] arrayForKey:@"categories"] mutableCopy]; 上面的行会产生泄漏:您首先分配一个数组,然后立即将另一个数组分配给跟踪您分配的数组的同一指针。 在第二行之后,您无法释放第一个数组。 至于主要问题,我怀疑是检查 if (![[NSUserDefaults stand ...
-
ABRecordID肯定会做出改变(通过多次机器联系同步,很难学会了这一点) Matt Gemmell在iphone-dev-tips-for-synced-contacts上有一篇很好的文章 我不存储复合名称,而是存储ABRecordId,名字,姓氏,电子邮件地址和电话号码(最后两个名称由我的应用程序直接使用)。 如果我没有受到打击 ABRecordRef aRef = ABAddressBookGetPersonWithRecordID(addressBook, aRecordId); 我使用一堆代 ...
-
字典中的某些对象或键具有类,不支持属性列表序列化。 请参阅此答案以获取详细信息: 属性列表支持ObjC类型 我建议检查键“profile_picture”的对象 - 它可能是NSURL。 如果这没有帮助,您可以使用以下代码来识别不兼容的对象: for (id key in userObjectDictionary) { NSLog(@"key: %@, keyClass: %@, value: %@, valueClass: %@", key, NSStringFromClass ...
-
“知道为什么吗?” 是: [[NSUserDefaults standardUserDefaults] setObject:[[DIOSSession sharedSession] user] forKey:@"diosSession"]; 我不知道[[DIOSSession sharedSession] user]是什么,但只能存储NSArray , NSDictionary , NSString , NSData , ...